The reason is we will only be checking certain conditions on the form -- and if those conditions pass, then the rest of the form's inputs are assumed valid (otherwise we'd validate them in the function! The first statement checks to see if the line1.value is NOT "Java Script".If it is NOT set to "Java Script", the flag is set to false. With the flag set to false, the statement to submit the form is not executed.One issue with the Regex above is it’ll fail on this format: That’s it.Anything beyond this is going to be too opinionated.Once you have an HTML form up and running, you will often want to make sure that all the important fields are filled in.For example, if you are going to send an email confirmation letter, the email address should be included in the form fields, and it should be an email address that works.
Most error checking programs check each field one at a time, and display one error at a time.
I hope this article is useful for all students and beginners.
If you have any suggestion related to this article then please contact me.
With that said, we’ll start off with the most permissive solution and work our way towards the other end. That’s typically all I ever assume about an email address.
If the email the user types in doesn’t follow that structure, odds are they made a typo.