Reputation: 1077
Can someone please tell me how does client side regular expressions validation differ from the regex checking done on the server?
Any references to asp.net validation control shall be appreciated.
Upvotes: 0
Views: 255
Reputation: 13020
The major difference between server- and client-side validation is in where the validator intercepts the processing. See the ASP.NET Page Life Cycle Overview to understand where validation occurs on the server. To better understand how validation works on the client see Client-Side Validation for ASP.NET Server Controls and How to: Validate with a Custom Function for ASP.NET Server Controls.
In the case of the RegularExpressionValidator, it includes both Javascript, which runs on the client, and .NET code, which runs on the server. If Javascript is disabled client side validation does not run at all. Depending on the browser, ASP.NET will attempt to gracefully degrade client-side functionality if some features are unsupported. Server-side validation always occurs.
Upvotes: 1
Reputation: 5213
In asp.net, RegularExpressionValidator control can perform both client-side and server-side validation.
Otherwise, JavaScript RegExp object will be used to perform client side validation, while .NET Regular Expression Object Model will do the work server side.
In general, if client scripting is disabled, client-side validation will not run. In this case, server-side validation is required. Unobtrusive JavaScript should grant a graceful degradation of the functionalities depending on the client scripting capabilities.
Upvotes: 1
Reputation: 2524
The differences are primarily based upon the differences in the Regex engine used. Javascript has it's own regex engine, and there are differences between how it works in comparison to .net's regex engine.
Both are based upon the Perl regex engine, but there are certainly some differences.
More information can be found here.
Upvotes: 0