/*
  Intended to validate form fields
*/

function validateDate (field) {

    /*

       Validates a field against the following:-

       \d{4} = four digits
       \- = literal minus
       d{1,2} = one or two digits

       Takes a field element as a parameter and
       returns true for a match, false for not

    */

    return $(field).val().match( /\d{4}\-\d{1,2}\-\d{1,2}/ );
}

function validateTimePair(fieldA, fieldB) {
    /*
       Validates two time fields against each other.
    */
    var fieldA_matches = $(fieldA).val().split( /\:/ );
    var fieldB_matches = $(fieldB).val().split( /\:/ );

    function verifyAll(match_group) {
        /*
           Validates that the group matches are both
           valid time portions.

           i.e. 04 or 12.
        */
        for (idx in match_group) {
            if (!match_group[idx].match( /\d{1,2}/ )) {
                return false;
            }
        }
        return true;
    }

    if (!verifyAll(fieldA_matches) && !verifyAll(fieldB_matches)) {
        return false;
    }

    var min_diff = fieldB_matches[1] - fieldA_matches[1];
    var hour_diff = fieldB_matches[0] - fieldA_matches[0];
    if (min_diff < 0) {
        min_diff = min_diff + 60;
        hour_diff--;
    }

    if (hour_diff < 0) {
        return false;
    } else {
        return true;
    }
}

function validateTime (field) {

    /*

       Validates a field against the following:-

       \d{1,2} = two digits
       \: = literal colon
       \d{1,2} = two digits
       \d{1,2}? = two optional digits

       Takes a field element as a parameter and
       returns true for a match, false for not

    */

    return $(field).val().match( /\d{1,2}\:\d{1,2}(\:\d{1,2})?/ );
}

function stringMatch (fieldA, fieldB) {

    /*
       String matching function
    */

    return $(fieldA).val() === $(fieldB).val();
}

function checkStringLengths (stringArray, len) {
    /*
      Checks all strings in the array for
      a given length

      Takes an array of strings and an integer
      return true if all strings validate,
      false otherwise.
    */

    for (idx=0;idx<stringArray.length;idx++) {
        if (stringArray[idx].length < len) {
            return false;
        }
    }
    return true;
}

function emailValidate (element_name) {
    /*
       Validates an email address

       Takes a element tag and returns boolean if the
       value matches or not.
    */

    var email = $(element_name).val();

    /*
      [A-Za-z0-9_.]+ = matches all alphanumeric characters with _ and .
      @ = matches @
      \.[A-Za-z]+ = matches . with any length alphanumeric string after
    */
    return email.match( /^[A-Za-z0-9_.]+@[A-Za-z0-9_.]+\.[A-Za-z]+$/ );
}

@@ -328,38 +328,16 @@
   return
- $(field).val().match(
  /%5Cd%7B4%7D%5C
@@ -354,17 +354,37 @@
 %5Cd%7B1,2%7D/
- 
+g.test($(field).val()
 );%0A%7D%0A%0Afu
@@ -1164,16 +1164,17 @@
 hes%5B0%5D;%0A
+%0A
     if (
@@ -1671,30 +1671,8 @@
 turn
- $(field).val().match(
  /%5Cd
@@ -1698,17 +1698,37 @@
 %7B1,2%7D)?/
- 
+g.test($(field).val()
 );%0A%7D%0A%0Afu
@@ -2497,16 +2497,18 @@
 a-z0-9_.
+%5C-
 %5D+ = mat
@@ -2544,16 +2544,19 @@
 ers with
+ -,
  _ and .
@@ -2669,21 +2669,8 @@
 turn
- email.match(
  /%5E%5B
@@ -2680,16 +2680,18 @@
 a-z0-9_.
+%5C-
 %5D+@%5BA-Za
@@ -2697,16 +2697,18 @@
 a-z0-9_.
+%5C-
 %5D+%5C.%5BA-Z
@@ -2714,14 +2714,25 @@
 Za-z%5D+$/
- 
+g.test(email
 );%0A%7D%0A

Use the regexp object to test strings.