function validate(phoneField, format) {

   var num = phoneField.value.replace(/[^\d]/g,'');

   if(num.length != 10) {

        //Alert the user that the phone number entered was invalid.

        alert('Please enter a valid phone number including area code');                   

   } else {

        //Email was valid.  If format type is set, format the Phone to the desired style.

      

      //Format (xxx)-xxx-xxxx

        phoneField.value = "(" + num.substring(0,3) + ")-" +

                                    num.substring(3, 6) + "-" + num.substring(6);
	}
		}
