A regular expression is a special text for describing a string pattern.
Regular expressions are commonly used to validate user entered input fields like Email Address, Phone number, Name etc. The regular expression to be used depends on the requirement and can be framed.
Replace the var regex value with any regular expression you need to validate with. The validateForm() method should be called on the onSubmit event of the form –
<form id=”form1″ name=”form1″ method=”post” onsubmit=”return validateForm()”action=”~/URL”>
Hope this helps.
Thanks for checking out !