Behavior of RegularExpression attributes and client-side validation of ASP.NET MVC is different - by Tatsuro Shibamura

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 790366 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 6/18/2013 3:18:22 AM
Access Restriction Public


Behavior of RegularExpression attributes and client-side validation of ASP.NET MVC is different.

Regular expression of BCL is because it is incompatible with the ECMAScript, If JavaScript is disabled, the result of the verification is different.
Sign in to post a comment.
Posted by Microsoft on 8/2/2013 at 10:13 PM
Hi shiba-yan,

As you have discovered, .NET and JavaScript (ECMA) have somewhat different implementations of regular expressions. In particular, while .NET regular expressions have fairly comprehensive support for Unicode characters, the JavaScript implementation is more limited.

If you specifically want to allow 0-9 (half-width) you can use the regular expression "[0-9]+". If you want to allow full-width you can use the regular expression "[0-9]+". And if you want both, you can use "[0-90-9]+".

If you would like to learn more about these behaviors I refer you to the following sites:

Half-width and full-width Unicode characters:
JavaScript regex Unicode support:
Character class definitions: (specifically, check out the "\d" notes in the "Examples" section regarding character classes)

The ASP.NET Team
Posted by Microsoft on 6/19/2013 at 12:51 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 6/18/2013 at 3:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(