This starts by finding the first letter of the value entered in the name field using the index
notation (an index of 0 represents the first letter in a string). It then checks to see if the first
letter is an “X” and alerts the user to the mistake. It also uses the preventDefault()
method to stop the form from being submitted. Otherwise it returns true , which means
the form is submitted as normal.
If you refresh the page and enter a name beginning with “X” in the name field and then try
submitting the form, you should receive an error alert dialog as in the screenshot shown in
Search WWH ::