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.
Adobe provided a lot of infrastructure to do that with just a simple script.
However, there's a simpler way if you modify how the function is called.
as long as your onsubmit has 'return' before your function, then you can prevent the form from being submitted if you return false.
In the latter case, we set rc to false, and also display an error message.
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.
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.
So, having a text field contain that error message might be a good idea.