Click here to Skip to main content
15,890,043 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: How do I change the width of an aps textbox dynamically in a JavaScript function Pin
Stephen Holdorf27-Apr-15 2:47
Stephen Holdorf27-Apr-15 2:47 
GeneralRe: How do I change the width of an aps textbox dynamically in a JavaScript function Pin
jkirkerx27-Apr-15 6:12
professionaljkirkerx27-Apr-15 6:12 
Questionsend data from JavaScript to PHP Pin
Member 836750223-Apr-15 15:24
Member 836750223-Apr-15 15:24 
GeneralRe: send data from JavaScript to PHP Pin
Sascha Lefèvre24-Apr-15 4:21
professionalSascha Lefèvre24-Apr-15 4:21 
QuestionConfirmation Alert for browser. Pin
Member 1004598422-Apr-15 18:52
Member 1004598422-Apr-15 18:52 
Answer[Repost] Pin
Sascha Lefèvre22-Apr-15 19:18
professionalSascha Lefèvre22-Apr-15 19:18 
GeneralRe: [Repost] Pin
Sumanth Madireddy23-Apr-15 4:43
professionalSumanth Madireddy23-Apr-15 4:43 
Questionregex help Pin
Wombaticus18-Apr-15 0:26
Wombaticus18-Apr-15 0:26 
I want to force users to enter dates in a textbox as mm/yyyy

The following works:
XML
<html>
<head>
    <title></title>
    <script type="text/javascript" >
        function testFormat(v) {
            //var re = new RegExp("^([1-9]|1[0-2]|0[1-9])/(\d{4})$");
            var re = new RegExp(document.getElementById("txtR").value);
            if (v.match(re) && (v.length==7)) {alert('ok');} else { alert('oops');}
        }
    </script>
</head>
<body ><form runat="server" id="Form1">
    <input type="text" id="txtR" value="^([1-9]|1[0-2]|0[1-9])/(\d{4})$" style="width:200px;" />
    <br />
    <input type="text" id="txtA" onblur="testFormat(this.value)" style="width:100px;" />
</form></body>
</html>

However:
  1. Why does the commented out javascript line not work? Instead I have to use this silly workaround of putting the regular expression in a text field, (well, I can make this hidden) and reference that. It's the only way I can make it work - but it's daft.
  2. In order to force a 2-digit month, I have added the test for v.length==7 - but it must be possible to amend the regex to check for this? Damned if I can see how...

GeneralRe: regex help Pin
Wombaticus18-Apr-15 4:03
Wombaticus18-Apr-15 4:03 
AnswerRe: regex help Pin
thoiness18-Apr-15 13:13
thoiness18-Apr-15 13:13 
GeneralRe: regex help Pin
Wombaticus18-Apr-15 21:21
Wombaticus18-Apr-15 21:21 
GeneralRe: regex help Pin
Wombaticus21-Apr-15 11:13
Wombaticus21-Apr-15 11:13 
GeneralRe: regex help Pin
thoiness21-Apr-15 11:15
thoiness21-Apr-15 11:15 
GeneralRe: regex help Pin
Wombaticus21-Apr-15 11:21
Wombaticus21-Apr-15 11:21 
GeneralRe: regex help Pin
thoiness21-Apr-15 11:21
thoiness21-Apr-15 11:21 
GeneralRe: regex help Pin
Wombaticus21-Apr-15 11:28
Wombaticus21-Apr-15 11:28 
AnswerRe: regex help Pin
Kornfeld Eliyahu Peter18-Apr-15 21:36
professionalKornfeld Eliyahu Peter18-Apr-15 21:36 
GeneralRe: regex help Pin
Wombaticus18-Apr-15 22:45
Wombaticus18-Apr-15 22:45 
GeneralRe: regex help Pin
Kornfeld Eliyahu Peter18-Apr-15 22:51
professionalKornfeld Eliyahu Peter18-Apr-15 22:51 
GeneralRe: regex help Pin
Wombaticus18-Apr-15 23:01
Wombaticus18-Apr-15 23:01 
GeneralRe: regex help Pin
Kornfeld Eliyahu Peter18-Apr-15 23:07
professionalKornfeld Eliyahu Peter18-Apr-15 23:07 
AnswerRe: regex help Pin
Richard Deeming20-Apr-15 3:23
mveRichard Deeming20-Apr-15 3:23 
GeneralRe: regex help Pin
Wombaticus20-Apr-15 3:28
Wombaticus20-Apr-15 3:28 
QuestionTemplating systems, do we need them ? Pin
Mark C Lester17-Apr-15 22:15
Mark C Lester17-Apr-15 22:15 
Questionhow we can change colors in table cells with time duration Pin
Member 1132187815-Apr-15 20:28
Member 1132187815-Apr-15 20:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.