[jQuery] [validate] Validation + Mask + Regex. Please, help me out. Thank You.
Hello,
I am using masking and client validation in a form using:
Validator Plugin - http://bassistance.de/jquery-plugins/jquery-plugin-validation/
Masked Input Plugin - http://digitalbush.com/projects/masked-input-plugin
In an input I have a Date Time in the following format:
yyyy-mm-dd hh:mm:ss
I am adding the masking as follows:
jQuery(function($){
$("#UpdatedAt").mask("9999-99-99 99:99:99");
});
How can I validate my field integrating it with the mask and using a
Regex to be sure that the date time is valid?
I already have the Regex Expression:
^([0-9]{4})-([0-1][0-9])-([0-3][0-9])\s([0-1][0-9]|[2][0-3]):([0-5]
[0-9]):([0-5][0-9])$
The date and time are also required.
I already have the following:
// Form validation
$("#Edit").validate({
errorClass: "Error",
errorElement: "label",
rules: {
UpdatedAt: {required: true}
},
messages: {
UpdatedAt: {
required: "Insert Updated date and time"
},
},
});
Could someone please help me?
I have been trying all day but until now I wasn't able to make this
work.
Thanks,
Miguel