// JavaScript Document
// FORM FUNCTIONS
function butValidate_onclick(){
	var myForm = document.orderForm;
	var alertString = "Please complete the following on the form: \n";
	var focusElement;
	if (myForm.realname.value == "") {
		alertString = alertString + "-> name\n";
		if (focusElement == null)
			focusElement = 'realname';
	}
	if (myForm.email.value == "") {
		alertString = alertString + "-> email\n";
		if (focusElement == null)
			focusElement = 'email';
	}
	if (myForm.address1.value == "") {
		alertString = alertString + "-> address\n";
		if (focusElement == null)
			focusElement = 'address1';
	}
	if (myForm.city.value == "") {
		alertString = alertString + "-> city\n";
		if (focusElement == null)
			focusElement = 'city';
	}
	if (myForm.state.value == "") {
		alertString = alertString + "-> state\n";
		if (focusElement == null)
			focusElement = 'state';
	}
	if (myForm.zip1.value.length < 5) {
		alertString = alertString + "-> zip code\n";
		if (focusElement == null)
			focusElement = 'zip1';
	}

	if (focusElement != null) {
		alert(alertString);
		myForm.elements[focusElement].focus();
		//return false;
	} else {
		//return true;
		myForm.submit();
	}
}

function zip1_onblur()
{
	var txtZipCode1 = document.orderForm.zip1;

	if (isNaN(txtZipCode1.value) == true)
	{
		alert("Please enter a valid 5-digit number.");
		txtZipCode1.focus();
		txtZipCode1.select();
	}
}

function zip2_onblur()
{
	var txtZipCode2 = document.orderForm.zip2;
	if (txtZipCode2.value != "")
	{
		if (isNaN(txtZipCode2.value) == true)
		{
		alert("Please enter a valid 4-digit number.");
		txtZipCode2.focus();
		txtZipCode2.select();
		}
	}
}

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Roman Feldblum (web.developer@programmer.net) -->

var txtPhoneValue;
var txtPhone;

function getIt(txtPhone) {
	this.txtPhone = txtPhone;
	ValidatePhone();
}

function ValidatePhone(){
	txtPhoneValue = txtPhone.value;
	if (txtPhoneValue.length==3) {
		pp=txtPhoneValue;
		d4=txtPhoneValue.indexOf('(');
		d5=txtPhoneValue.indexOf(')');
		if(d4 == -1) {
			pp = "("+pp;
		}
		if(d5 == -1) {
			pp = pp+")";
		}

		document.orderForm.phone.value="";
		document.orderForm.phone.value=pp;
	}
	if(txtPhoneValue.length>3){
		d1=txtPhoneValue.indexOf('(')
		d2=txtPhoneValue.indexOf(')')
		if (d2==-1){
			l30=txtPhoneValue.length;
			p30=txtPhoneValue.substring(0,4);
			//alert(p30);
			p30=p30+")"
			p31=txtPhoneValue.substring(4,l30);
			pp=p30+p31;
			//alert(p31);
			document.orderForm.phone.value="";
			document.orderForm.phone.value=pp;
		}
	}
	if(txtPhoneValue.length>5){
		p11=txtPhoneValue.substring(d1+1,d2);
		if(p11.length>3){
		p12=p11;
		l12=p12.length;
		l15=txtPhoneValue.length
		//l12=l12-3
		p13=p11.substring(0,3);
		p14=p11.substring(3,l12);
		p15=txtPhoneValue.substring(d2+1,l15);
		document.orderForm.phone.value="";
		pp="("+p13+")"+p14+p15;
		document.orderForm.phone.value=pp;
		//obj1.value="";
		//obj1.value=pp;
	}
	l16=txtPhoneValue.length;
	p16=txtPhoneValue.substring(d2+1,l16);
	l17=p16.length;
	if(l17>3&&p16.indexOf('-')==-1){
			p17=txtPhoneValue.substring(d2+1,d2+4);
			p18=txtPhoneValue.substring(d2+4,l16);
			p19=txtPhoneValue.substring(0,d2+1);
			//alert(p19);
		pp=p19+p17+"-"+p18;
		document.orderForm.phone.value="";
		document.orderForm.phone.value=pp;
		//obj1.value="";
		//obj1.value=pp;
		}
	}

	setTimeout(ValidatePhone,100)
}


function detectEnter() {
	if(event.keyCode == 13) {
		butValidate_onclick();
	}
}