same regex validation works on server side but not on client side

Migliaido

New Member
I am using ASP.Net MVC to validate that a string will not contain more than 2 numbers in any form.I'm using the following server side code:\[code\][RegularExpression(@"[^\d]*\d?[^\d]*\d?[^\d]*",ErrorMessage = "More than 2 Numbers are not allowed")]\[/code\]That works great, but the following JavaScript code will always return \[code\]0\[/code\]:\[code\]>> var mystring = "test123"; >> var myregax = new RegExp("[^\d]*\d?[^\d]*\d?[^\d]*"); >> mystring.search(myregax); 0 >> mystring = "test"; "test" >> mystring.search(myregax); 0 \[/code\]What am I missing and what is the difference between the regular expression syntax of ASP.Net and JavaScript?
 
Back
Top