Fortunately, Java Script 1.2 has incorporated regular expressions.
In this article I will present a brief tutorial on the basics of regular expressions and then give some examples of how they can be used to simplify data validation.
[1-9] # 01-09 or 1-9 | # .[0-9] # 10-19 or 20-29 | # .3 # 30, 31 ) #end of group #1 / # follow by a "/" ( # start of group #2 0?
[1-9] # 01-09 or 1-9 | # .1 # 10,11,12 ) # end of group #2 / # follow by a "/" ( # start of group #3 (19|20)\d\d # 19[0-9][0-9] or 20[0-9][0-9] ) # end of group #3 The above regular expression is used to validate the date format in “dd/mm/yyyy”, you can easy customize to suit your need.
Validating user input is the bane of every software developer’s existence.
When you are developing cross-browser web applications this task becomes even less enjoyable due to the lack of useful intrinsic validation functions in Java Script.
Client side validation Validation done in the browser before sending the form data to the server using Java Script, j Query and VBScript is called client-side validation. Let us first create the web application with two web pages We are adding two web pages because our requirement is, in the first web page there is form data to be filled in by the user and only after validating the form data, the form will be redirected to the next page.
Importantance of returning false It's very important to use the return false statement after the condition block that return false so if validation determines that the business requirements are not met then the form cannot be submitted.Try switching to Design view and select the Regular Expression Validator on your page.Now have a look in the Properties tab of Visual Studio. “31/4/20100”, “31/04/2010” – April has 30 days only 8. “333/2/2008”, “29/02/200a” – day is invalid, year is invalid 7.