Wednesday, May 27, 2015

Validate date using jquery masked input plugin

I am using jquery masked input plugin for masking of input fields. I am using `GWT` and using jquery mask input function using `JSNI`.

 For date field having mask like "`MM/dd/yyyy`", 

how can I restrict user not to enter `month >12 or day >31`... 

My implementation is as follows: 

     $wnd.$.mask.definitions['y'] = '[12]';
    $wnd.$.mask.definitions['m'] = '[01]';
    $wnd.$.mask.definitions['d'] = '[0-3]';
    
        if (pattern== 'MM/DD/YYYY') {
    $wnd.$(id).mask("m9/d9/y999", {
    placeholder : p
        });

Here in month field, there are `2 digits(MM)`, 

 - first digit can be restricted to 0 to 1
 - second digit not able to control

I tried with conditional regex, not working fine.

Anything with conditional regex is also fine.

Basically I want user to enter only valid dates.

Please suggest.

Thanks.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment