// JavaScript Document

		String.prototype.stripSpaces = function( ){ return this.replace( /\s/g, "" ); };
		
		function IsEmpty(aTextField) {
		   if ((aTextField.value.length==0) ||
		   (aTextField.value==null)) {
			  return true;
		   }
		   else { return false; }
		}			
		
		function isPostCode(entry){ // CANADIAN CODES ONLY
		strlen=entry.length; if(strlen!=6) {return false;}
		entry=entry.toUpperCase();    // in case of lowercase characters
		// Check for legal characters in string - note index starts at zero
		if('ABCEGHJKLMNPRSTVXY'.indexOf(entry.charAt(0))<0) {return false;}
		if('0123456789'.indexOf(entry.charAt(1))<0) {return false;}
		if('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(2))<0) {return false;}
		if('0123456789'.indexOf(entry.charAt(3))<0) {return false;}
		if('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(4))<0) {return false;}
		if('0123456789'.indexOf(entry.charAt(5))<0) {return false;}
		return true;}
				
		 $(document).ready(function() {
		   $("#mysubmit").click(function() {
		   		
  			if (!IsEmpty(document.form1.postc) ){
				$("#postcode").attr("value", $("#postcode").attr("value").stripSpaces());
			 	if ( isPostCode( $("#postcode").attr("value") ) ){
			 		$("#form1").submit();
				}else{
					alert("please enter a valid postal code" );
				}
			 }else{
			 	alert("please enter a valid postal code" );
			 }
			 
  
			});
		 });	
