This function builds an array of elements such as text boxes that require values, an array of select list elements that require a selection, and an array of radio button group elements that require a checked value.
These lists are passed to fail, then they display an appropriate message to the user and return false, which cancels the submission of the form.
With Java Script, however, we can do much more on the client side.
The benefit Java Script provides for the server is that it shifts some work that might otherwise be done on the server to the client, and it reduces the number of server requests.
The benefit Java Script provides to the user is that it provides immediate feedback without a delay while the browser fetches a new page.
Of course, in Perl we could easily do checks like this with a regular expression.
For example, we could match social security number with function.
We won't look at the CGI script here, although we will discuss saving data like this CGI script would handle a request coming from a page with Java Script validation just like it would handle any other request.