Postal Code Validation in JAvascript

Postal Code Validation in JAvascript

Hi,

    I need to check the postal code is h2b3f4

But i worked as h2bfff and so on... For Eg: first three character is below the searchwords and next three character is anything. this is i worked.

But now i want first three character is validated form search words and next three character is 3G3

That means Number Letter Number... Please any one help.. to change my below code



Below code:


function doSubmit(myform){
        searchWords = ['h7l', 'h1h', 'h8t' ,'h1g','h1j','h1k','h1m','h1p','h1r','h1s','h1t','h1v','h1w','h1x','h1y','h1z','h2a','h2b','h2c','h2e','h2g','h2h','h2j','h2k','h2n','h2l','h2m','h2p','h2r','h2s','h2t','h2v','h2w','h2x','h2y','h2z','h3a','h3b','h3c','h3e','h3g','h3h','h3j','h3k','h3l','h3m','h3n','h3p','h3r','h3s','h3t','h3v','h3w','h3x','h3y','h3z','h4a','h4b','h4c','h4e','h4g','h4h','h4j','h4k','h4l','h4m','h4p','h4n','h4r','h4s','h4t','h4v','h4w','h4x','h4y','h7m','h7n','h7r','h7p','h7s','h7t','h7v','h7w','h7x','h7y','h8n','h8p','h8r','h8s','h8t','h8y','h8z','h9a','h9b','h9c','h9e','h9g','h9h','h9j','h9k','h9p','h9r','h9s','h9w','h9x','j7t','j7v','j7w','h7g','h7e'];

        var pattern = new RegExp(searchWords.join("|"), "gi");
// var pos = /^([0-9][A-Z][0-9])$/;

        var pinCodevalue = document.getElementById('postal').value;
// var mytool_array=pinCodevalue.split(searchWords);
// alert(mytool_array[0]+" "+mytool_array[1]+" "+mytool_array[2]);
        
var validationResult = null;
// var text = "aaabbbccc";
// if( pinCodevalue.charAt(0)=='h')
//{
//
////do something
//alert("pass");
//alert(pinCodevalue.charAt(0)(1)(2));
//}

        validationResult = pinCodevalue.match(pattern);
        var mystring= pinCodevalue.substring(0, 3);
var mystringresult= mystring.match(pattern);
//alert(mystring);
var strlen = pinCodevalue.length;
// alert(strlen);
 
if(strlen==6)
{
if(mystringresult == null)
{
window.location.href="Estimation_Gratuite_new.html"
}


else {
            var postal = $('input[name=postal]');

         var postal =  postal.val();

      window.parent.location="estimate.php?postal="+postal;
        }
}
else
{
// alert("Please enter six letters postal code");
window.location.href="Estimation_Gratuite_new.html"

document.getElementById('postal').focus();
return false;
}

       // if (pinCodevalue.length > 3) {
//            validationResult = null;
//        }
//
//        if (validationResult == null) {
//   window.location.href="free_estimate_new.html"
// }
//
//        else {
//            var postal = $('input[name=postal]');
//
//         var postal =  postal.val();
//
//      window.parent.location="estimate.php?postal="+postal;
//        }


    }