The function formNotEmpty(elem) checks the field value passed into the function in the elem variable. We set the variable field to the value of the field passed in the elem variable. The if statement checks the length of field and if its equal to 0 false is returned if the length is longer than 0 true is returned.
Here in formIsEmail(elem) we check the value of the field passed against a regex. We set regex to a regular expression that verifies a valid email address. We return the test of the field value. Performing .test against a variable set to a regex will return true or false based on the value matching. If you wanted to get hardcore with email checking you could replace ([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z]) with a regex containing all the top level domains.
This function stores our error messages. We pass it the number of the check the failure was on. A simple switch statement determines which message to display.