To add a validation prompt, add the following line of code to your form, just under your input field.
This will clean up the prompt message once the user corrects their mistake.
To create a validation for your name field, type the following line into your and assign it the regex of any capital letter (A-Z), any lower case letter (a-z), a space, a hyphen or an apostrophe.
With this regex rule saved, we can then run a test on our input to see if what was entered matches our defined rule. Save this out and refresh the page in your browser.
A much better way of solving this problem is to include inline validation that checks the user’s input as she progresses.
As I mentioned before, information is passed to the validation function in the event object, and in the code we see that the member ‘value’ is used to communicate the current value of the field.
The member ‘rc’ (or return code) is used to communicate back if the validation was successful or not.This is handy because we don’t really want to allow our user to submit a form with invalid data.