When you play around with the function, you’ll notice that the validation function is only called when the focus leaves the field, so you have to click outside of the field to actually make that error message pop up.In that case, the previous value of the field is restored, and the user has to enter the data again.There are two types of validation: client side validation and server side validation.In client side validation the data is validated in the browser using Java Script before submitting the data to the server.The member ‘rc’ (or return code) is used to communicate back if the validation was successful or not.In the latter case, we set rc to false, and also display an error message.
One of the questions I get asked again and again is how to validate a field value in an Acro Form with a custom validation script.
This is not always desired (for more complicated data, it will probably be much easier to take a look, correct that one typo and continue with the rest of the form), so my preference is actually to mark the field so that the user knows which field needs to be corrected, and have the validation script not report a validation error back to the field: Using this method has implications on the form submission process: The form no longer can verify that the data is correct, so the submission function needs to do another round of validation to see if any of the required fields are not correct (one way to do that is to test all relevant fields to see if the text color is using the error color, or we can use global variables to store the validation state).
Another thing I like to do is to display the validation error message on the form in an otherwise hidden field: The problem with our last solution is that if the user saves a partially filled form, and picks it up at a later time, that error message that popped up is long gone, and the only indication that there is something wrong with the form is the modified field color.
All credit cards are 16 digits and the 16th digit can be calculated based on the first 15 numbers.
This means you can use Java Script to check for, and alert the user to, credit card typos.