


// Checks the Email field validity.
function check_email(pstr, isrequired) {
var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;  // not valid
var reg2 =/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;

	if (!(isrequired) && pstr == "") 
		return true;
			
	if (!(reg1.test(pstr)) && reg2.test(pstr))
		return true;
			
	alert("\"" + pstr + "\" is an invalid e-mail!");
	return false;
}





// Trims string.
function trim_str(pstr) {
	// triming from left
	while ("" + pstr.charAt(0) == " ") {
		pstr = pstr.substring(1, pstr.length);
	}
					
	// triming from right
	while ("" + pstr.charAt(pstr.length-1) == " ") {
		pstr = pstr.substring(0, pstr.length-1);
	}
	
	return pstr ;
}


<!--
	String.prototype.isIPAddress = function () {if (!this.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/)) return false; for (var i=1; i<=4; i++) {if (RegExp['$' + i] > 255) return false}; return true}
// -->

/*
	USAGE:
	IP Address<input type="text" onchange="if (!this.value.isIPAddress()) {alert('That does not appear to be a valid IP Address.'); this.value=''; this.focus()}">
*/


