i am trying to validate date which Accept only dd/mm/yyyy.
i have use the following code to validate but it always show me alert.
what wrong with my code ??
when i used , var bevalue ='10/10/1989'; it work fine.
And in my code i used, value = $(this).val(); to get value.
then convert it to string
EDIT:
$('input, textarea').live('blur', function () {
var field = $(this).attr('name');
var value = $(this).val();
if(field=='birthday')
{
var bevalue = String(value);
var regbday =/^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d+$/;
if(regbday.test(bevalue) == false)
{
alert('please Enter Birth date in dd/mm/yyyy');
return false;
}
}
Thanks Everyone for reply my mistake in Regexp. I accepted answer.
this? We need more code. And you should first debug to see what'svalue.?:to prevent sub-expressions from being captured if you're not using them.+. So therefore I can enter in10/10/12345679. Removing the+fixes that. if it isn't working, thenvalueis wrong and to help we will need to understand how you are getting value's value like @dystroy said