////////////////////////////////////////////////////////////////////////////
// Function isEmpty(str)                                                  //
//   - checks to see if a form field 'str' is empty                       //
////////////////////////////////////////////////////////////////////////////
function isEmpty(str) {
   var empty = (str == null || str == "") ? true : false
   return empty
}

////////////////////////////////////////////////////////////////////////////
// Function numbersonly(e)                                                //
//   - only allows numerical characters to be entered in a form field     //
////////////////////////////////////////////////////////////////////////////
function numbersonly(e){
   var unicode=e.charCode? e.charCode : e.keyCode
   if (unicode!=8 && unicode!=9 && unicode!=13){ //if the key isn't the backspace, tab 
                                                 // or CR key (which we should allow)
      if (unicode<48||unicode>57) //if not a number
         return false //disable key press
   }
}

////////////////////////////////////////////////////////////////////////////
// Function limitlength(obj, length)                                      //
//   - limits the number of characters entered in a form field to 'length'//
////////////////////////////////////////////////////////////////////////////
function limitlength(obj, length){
   var maxlength=length
   if (obj.value.length>maxlength)
      obj.value=obj.value.substring(0, maxlength)
}

////////////////////////////////////////////////////////////////////////////
// Function requirelength(obj, length)                                      //
//   - alerts user if the number of characters entered in a form field is //
//     not equal to a required 'length'                                   //
////////////////////////////////////////////////////////////////////////////
function requirelength(obj, length){
   var required_length=length
   alert("checking length, comparing "+obj.value.length+" with "+requiredlength)
   if (obj.value.length != required_length)
      alert("Enter exactly "+length+" characters in this field.")
	  obj.focus()
	  return false
}


////////////////////////////////////////////////////////////////////////////
// Function isValidPhone(str)                                             //
//   - checks to see if a form field 'str' is a valid phone number        //
////////////////////////////////////////////////////////////////////////////
function isValidPhoneOrBlank(str) {
   var empty = (str == null || str == "") ? true : false;
   if (!empty) {
      var tempph = str;
      tempph = tempph.replace(/'/g,"");
	  tempph = tempph.replace(/-/g,"");
	  tempph = tempph.replace(/\(/g,"");
	  tempph = tempph.replace(/\)/g,"");
      tempph = tempph.replace(/ /g,"");
      tempph = parseInt(tempph);
	  var notanumber = isNaN(tempph);
	  var numlength = tempph.toString().length;
      if (notanumber) { 
         return false;
      } else if (numlength != 10) {
         return false;
      } else {
         return true;
	  }
   } else {
      return true;
   }
}

////////////////////////////////////////////////////////////////////////////
// Function reformatPhone(str)                                            //
//   - reformats a form field 'str' into a (999)999-9999 format           //
////////////////////////////////////////////////////////////////////////////
function reformatPhone(str) {
   var empty = (str == null || str == "") ? true : false
   if (!empty) {
      var tempph = str
      tempph = tempph.replace(/'/g,"")
	  tempph = tempph.replace(/-/g,"")
	  tempph = tempph.replace(/\(/g,"")
	  tempph = tempph.replace(/\)/g,"")
      tempph = tempph.replace(/ /g,"")
	  var newphone = "(" + tempph.substr(0,3) + ") " + tempph.substr(3,3) + "-"
	  newphone += tempph.substr(6,4)
	  return newphone
   }
   return ""
}

<!-- This script is based on the javascript code of Roman Feldblum (web.developer@programmer.net) -->
<!-- Original script : http://javascript.internet.com/forms/format-phone-number.html -->
<!-- Original script is revised by Eralper Yilmaz (http://www.eralper.com) -->
<!-- Revised script : http://www.kodyaz.com -->

var zChar = new Array(' ', '(', ')', '-', '.');
var maxphonelength = 13;
var phonevalue1;
var phonevalue2;
var cursorposition;

function ParseForNumber1(object){
phonevalue1 = ParseChar(object.value, zChar);
}
function ParseForNumber2(object){
phonevalue2 = ParseChar(object.value, zChar);
}

function backspacerUP(object,e) {
if(e){
e = e
} else {
e = window.event
}
if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}

ParseForNumber1(object)

if(keycode >= 48){
ValidatePhone(object)
}
}

function backspacerDOWN(object,e) {
if(e){
e = e
} else {
e = window.event
}
if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}
ParseForNumber2(object)
}

function GetCursorPosition(){

var t1 = phonevalue1;
var t2 = phonevalue2;
var bool = false
for (i=0; i<t1.length; i++)
{
if (t1.substring(i,1) != t2.substring(i,1)) {
if(!bool) {
cursorposition=i
bool=true
}
}
}
}

function ValidatePhone(object){

var p = phonevalue1

p = p.replace(/[^\d]*/gi,"")

if (p.length < 3) {
object.value=p
} else if(p.length==3){
pp=p;
d4=p.indexOf('(')
d5=p.indexOf(')')
if(d4==-1){
pp="("+pp;
}
if(d5==-1){
pp=pp+")";
}
object.value = pp;
} else if(p.length>3 && p.length < 7){
p ="(" + p;
l30=p.length;
p30=p.substring(0,4);
p30=p30+")"

p31=p.substring(4,l30);
pp=p30+p31;

object.value = pp;

} else if(p.length >= 7){
p ="(" + p;
l30=p.length;
p30=p.substring(0,4);
p30=p30+")"

p31=p.substring(4,l30);
pp=p30+p31;

l40 = pp.length;
p40 = pp.substring(0,8);
p40 = p40 + "-"

p41 = pp.substring(8,l40);
ppp = p40 + p41;

object.value = ppp.substring(0, maxphonelength);
}

GetCursorPosition()

if(cursorposition >= 0){
if (cursorposition == 0) {
cursorposition = 2
} else if (cursorposition <= 2) {
cursorposition = cursorposition + 1
} else if (cursorposition <= 5) {
cursorposition = cursorposition + 2
} else if (cursorposition == 6) {
cursorposition = cursorposition + 2
} else if (cursorposition == 7) {
cursorposition = cursorposition + 4
e1=object.value.indexOf(')')
e2=object.value.indexOf('-')
if (e1>-1 && e2>-1){
if (e2-e1 == 4) {
cursorposition = cursorposition - 1
}
}
} else if (cursorposition < 11) {
cursorposition = cursorposition + 3
} else if (cursorposition == 11) {
cursorposition = cursorposition + 1
} else if (cursorposition >= 12) {
cursorposition = cursorposition
}

var txtRange = object.createTextRange();
txtRange.moveStart( "character", cursorposition);
txtRange.moveEnd( "character", cursorposition - object.value.length);
txtRange.select();
}

}

function ParseChar(sStr, sChar)
{
if (sChar.length == null)
{
zChar = new Array(sChar);
}
else zChar = sChar;

for (i=0; i<zChar.length; i++)
{
sNewStr = "";

var iStart = 0;
var iEnd = sStr.indexOf(sChar[i]);

while (iEnd != -1)
{
sNewStr += sStr.substring(iStart, iEnd);
iStart = iEnd + 1;
iEnd = sStr.indexOf(sChar[i], iStart);
}
sNewStr += sStr.substring(sStr.lastIndexOf(sChar[i]) + 1, sStr.length);

sStr = sNewStr;
}

return sNewStr;
}

<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site:  http://www7.ewebcity.com/cyanide7 -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function formatCurrency(num) {
num = parseFloat(num.toString().replace(/\$|\,/g,''));
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}
//  End -->

function formatPhone(phonefield) {
   var num = phonefield.value;
   var empty = (num == null || num == "") ? true : false
   var numstr = "";
   var numstr1 = "";
   var numstr2 = "";
   var numstr3 = "";
   
   num = num.replace(/'/g,"")
   num = num.replace(/-/g,"")
   num = num.replace(/\(/g,"")
   num = num.replace(/\)/g,"")
   num = num.replace(/ /g,"")
   num = parseInt(num)
   var numlength = num.toString().length
   if(isNaN(num)) {
	  if (!empty) {
	     alert("Enter a valid, 10-digit phone/fax number.  Enter only the numbers. The field will auto-format.");
	     phonefield.focus();
	  }
	  return (numstr);
   } else if (numlength == 10) {
	  numstr1 = num.toString().substr(0,3);
	  numstr2 = num.toString().substr(3,3);
	  numstr3 = num.toString().substr(6,4);
      numstr = "(" + numstr1 + ")" + numstr2 + "-" + numstr3;
      return (numstr);
   } else {
	  alert(num.toString().length + " digits entered. Enter a valid, 10-digit phone/fax number.  Enter only the numbers. The field will auto-format.");
	  phonefield.focus();
	  return (numstr);
   }
}

function checklength(field, targetlength) {
	var val = field.value.toString();
	var length = val.length;
	if (!isEmpty(val) && length != targetlength) {
	   alert ("This field must contain exactly "+targetlength+" characters.");
	   field.focus();
	   return false;
	}
}

function checklength(field, targetlength) {
	var val = field.value.toString();
	var length = val.length;
	if (!isEmpty(val) && length != targetlength) {
	   alert ("This field must contain exactly "+targetlength+" characters.");
	   field.focus();
	   return false;
	}
}

////////////////////////////////////////////////////////////////////////////
//  Script by hscripts.com   modified by Vartech Services                 //
////////////////////////////////////////////////////////////////////////////
function isAlphaNumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
	{
		var alphaa = numaric.charAt(j);
		var hh = alphaa.charCodeAt(0);
		if(!((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123)))
            return false;
 	}
	return true;
}

////////////////////////////////////////////////////////////////////////////
//  isValidEmailAddress                                                   //
////////////////////////////////////////////////////////////////////////////
function isValidEmailAddress(email)
{
	var emailRegExp = /^(\w+@)([a-z0-9\-]{2,})(\.+[a-z]{2,})$/i;
	if (emailRegExp.test(email)) {
      return true;
	} else {
		return false;
	}
}

////////////////////////////////////////////////////////////////////////////
// Function validateChamp_Email()                                        //
////////////////////////////////////////////////////////////////////////////
function validateChamp_Email(form) {
   if (isEmpty(form.subject.value)) {
      alert ("Please enter a subject for your email message.")
	  form.subject.focus()
	  return false
   }
   if (isEmpty(form.fname.value)) {
      alert ("Please enter your First Name.")
	  form.fname.focus()
	  return false
   }
   if (isEmpty(form.lname.value)) {
      alert ("Please enter your Last Name.")
	  form.lname.focus()
	  return false
   }
   if (isEmpty(form.sender.value)) {
      alert ("Please enter your Email Address.")
	  form.sender.focus()
	  return false
   }
   if (isEmpty(form.message.value)) {
      alert ("Please enter your email message.")
	  form.message.focus()
	  return false
   }
   return true
}

////////////////////////////////////////////////////////////////////////////
// Function validateCourse_Reg()                                        //
////////////////////////////////////////////////////////////////////////////
function validateCourse_Reg(form) {
   if (isEmpty(form.fname.value)) {
      alert ("Please enter your First Name.")
	  form.fname.focus()
	  return false
   }
   if (isEmpty(form.lname.value)) {
      alert ("Please enter your Last Name.")
	  form.lname.focus()
	  return false
   }
   if (form.fname.value == form.lname.value) {
      alert ("Please enter a valid First Name and Last Name.")
	  form.fname.focus()
	  return false
   }
   if (isEmpty(form.pri_email.value)) {
      alert ("Please enter your Email Address.")
	  form.pri_email.focus()
	  return false
   }
   if (!isValidEmailAddress(form.pri_email.value)) {
      alert ("Please enter a valid Email Address.")
	  form.pri_email.focus()
	  return false
   }
   return true
}



