When the submit button is pressed, or the Enter key in one of the fields,...

 the validate function is called.

Here, three field validating functions are called,...

 each one of which can set the global boolean 'bok' to false,...

 in case an error is detected.

Looking at the name validation,...

 we notice that error strings can be thrown,...

 that are caught here.

'throw' implies : 'skip the rest and go to the catch'.

We can show useful error messages depending on the error string's value.

These 'span's are used to show possible error messages.

Using a regular expression : characters that are NOT (^) letters, space, single quote or dash are not allowed.

The 'test' method returns a boolean, true or false.

The name has to contain at least one uppercase letter. Notice the NOT operator, ! , up front.

The date has to be entered as shown, year, month and day, separated by slashes.

Parse into an array.

Full year, month and day to construct a Date instance.

-1, because 0 is January ,11 is December !!

Since the Date constructor is too forgiving ( passing in 32nd of July yields 1st of August ! ), we check if year, month and day of the created Date instance match the input.
!= not equal, || or

If the Date construction fails, so its methods can't be called, the script engine throws an error that ends up in the 'catch'.


To have a comparison on date only, the time fields are set to zero (as they already are in 'dt').

Date entered must be a future date.

Regarding the income check :

Since parseInt is too lenient,...

 we do a character check anyway, only digits allowed.

Not too high.


When there are no errors, the 'validate' function returns true, ...

 that is also returned by the 'onsubmit' handler,...

 so in that case the form contents is sent to the URL indicated by 'action' . Otherwise, it isn't.


Convenient for simplistic debugging.


Making an instance of the RegExp object. 'test' is one of its methods.