2

I have problems adding a custom validation to validate fields entering time (with jQuery Validation Engine), in the following manner: hh:mm (e.g. 12:30);

As far as I know I should add the following

"timeFormat":{ 
    "regex":"/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/",
    "alertText":" errormessage in the locale chosen"}                           
}

in jquery.validationEngine-(the locale).js

and add the following in the input field class="validate[custom[timeFormat]]"

But for some reason it doesn't work, whatever I've entered it displays that the field is not valid. I suspect that my regex is something wrong, but I've tested it in http://gskinner.com/RegExr/ and it seems pretty OK.

Suggestions?

1 Answer 1

1

You don't need the quotes around your regex. Try this here:

"timeFormat":{
    "regex": /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/,
    "alertText":" errormessage in the locale chosen"                           
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.