asp.net - Regex for fixed number in javascript/jquery -
i want validate textfield user enter number like.. should start 'arrn' , upto 5 numeric fields. number can be.. arrn1 or arrn12 or arrn123 not arrn123456 5 numeric allowed.
can have regex same in javascript validate?
i tried regex ['arrn'@[5]] not sure regex syntax.
you can use follwong code check pattern. check pattern in onblur event of input.
$('input').on('blur',function(){ var val = $(this).val(); if(/^arrn\d{1,5}$/.test(val)) alert('val ok'); else { //$(this).val(''); alert('val not correct.'); } });
Comments
Post a Comment