Login   Register  
PHP Classes
elePHPant
Icontem

File: formValidators.js

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of One Step Solutions  >  Grid  >  formValidators.js  >  Download  
File: formValidators.js
Role: Auxiliary data
Content type: text/plain
Description: formValidators.js
Class: Grid
Display database query results in an HTML table
Author: By
Last change:
Date: 4 years ago
Size: 8,040 bytes
 

Contents

Class file image Download
// JavaScript Document

function checkmail(email)
{
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = email;
   if(reg.test(address) == false)
   {
      return false;
   }
   return true;
}

function checkmail2(email)
{
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = email;
   if(reg.test(address) == false)
   {
	   alert('provide correct email');
      return false;
   }
   return true;
}


function alphaNumOnly(evt)
{	
	var charCode = (evt.which) ? evt.which : window.event.keyCode;

	if (charCode <= 13)
	{
		return true;
	}
	else
	{
		var keyChar = String.fromCharCode(charCode);
		var re = /[a-zA-Z0-9]/
		return re.test(keyChar);
	}	
}

function alphaNumSpaceOnly(evt)
{	
	var charCode = (evt.which) ? evt.which : window.event.keyCode;

	if (charCode <= 13 || charCode == 32)
	{
		return true;
	}
	else
	{
		var keyChar = String.fromCharCode(charCode);
		var re = /[a-zA-Z0-9,_-]/
		return re.test(keyChar);
	}	
}

function alphaOnly(evt)
{	
	var charCode = (evt.which) ? evt.which : window.event.keyCode;

	if (charCode <= 13)
	{
		return true;
	}
	else
	{
		var keyChar = String.fromCharCode(charCode);
		var re = /[a-zA-Z]/
		return re.test(keyChar);
	}	
}

function numOnly(evt)
{	
	var charCode = (evt.which) ? evt.which : window.event.keyCode;

	if (charCode <= 13)
	{
		return true;
	}
	else
	{
		var keyChar = String.fromCharCode(charCode);
		var re = /[0-9_-]/
		return re.test(keyChar);
	}	
}

function nochk()
{
	document.getElementById('cncl').value='1';
	return true;
}

function nochk()
{
	document.getElementById('cncl2').value='1';
	return true;
}

function updateuserform()
{
	if(document.getElementById('cncl').value!='1')
	{
		if(document.getElementById('reg_No').value.length==0)
		{
			alert('Fill Registeration No field');
			document.getElementById('reg_No').focus();
			return false;
		}
		else if(document.getElementById('RFID').value.length==0 && document.getElementById('RFID').disabled!=true)
		{
			alert('Fill RFID field');
			document.getElementById('RFID').focus();
			return false;
		}
		else if(document.getElementById('fname').value.length==0)
		{
			alert('Fill first name field');
			document.getElementById('fname').focus();
			return false;
		}
		else if(document.getElementById('lname').value.length==0)
		{
			alert('Fill last name field');
			document.getElementById('lname').focus();
			return false;
		}
		else if(document.getElementById('mobile').value.length==0)
		{
			alert('Fill mobile no field');
			document.getElementById('mobile').focus();
			return false;
		}
		else if(document.getElementById('phone').value.length==0)
		{
			alert('Fill phone no field');
			document.getElementById('phone').focus();
			return false;
		}
		else if(document.getElementById('phone').value.length==0)
		{
			alert('Fill phone no field');
			document.getElementById('phone').focus();
			return false;
		}
		else if(document.getElementById('M').checked==false && document.getElementById('F').checked==false)
		{
			alert('Pease specify the gender');
			document.getElementByName('sex').focus();
			return false;
		}
		else if(document.getElementById('address').value.length==0)
		{
			alert('Fill in the address');
			document.getElementById('address').focus();
			return false;
		}
		else if(document.getElementById('city').value.length==0)
		{
			alert('Fill in the city field');
			document.getElementById('city').focus();
			return false;
		}
		else if(document.getElementById('pcode').value.length==0)
		{
			alert('Fill in the postal code field');
			document.getElementById('pcode').focus();
			return false;
		}
		else if(!checkmail(document.getElementById('email').value))
		{
			alert('Enter the email correctly');
			document.getElementById('email').focus();
			return false;
		}
		else if(document.getElementById('username').value.length==0)
		{
			alert('Fill in the username field');
			document.getElementById('username').focus();
			return false;
		}
		else if(document.getElementById('chkavail').value=='0')
		{
			alert('This username already exists\nPlease choose another username');
			document.getElementById('username').focus();
			return false;
		}
	}
	
	
	
	return true;
}


function updatepass()
{
	if(document.getElementById('cncl2').value!='1')
	{
		if(document.getElementById('password').value.length<5)
		{
			alert('Password must be of atleast 5 chars');
			document.getElementById('password').focus();
			return false;
		}
		else if(document.getElementById('cpass').value!=document.getElementById('password').value)
		{
			alert('Confirm password field must match password field');
			document.getElementById('cpass').focus();
			return false;
		}
	}
	
	
	
	return true;
}


function adduserform()
{
	if(document.getElementById('cncl').value!='1')
	{
	
		if(document.getElementById('reg_No').value.length==0)
		{
			alert('Fill Registeration No field');
			document.getElementById('reg_No').focus();
			return false;
		}
		else if(document.getElementById('RFID').value.length==0 && document.getElementById('RFID').disabled!=true)
		{
			alert('Fill RFID field');
			document.getElementById('RFID').focus();
			return false;
		}
		else if(document.getElementById('fname').value.length==0)
		{
			alert('Fill first name field');
			document.getElementById('fname').focus();
			return false;
		}
		else if(document.getElementById('lname').value.length==0)
		{
			alert('Fill last name field');
			document.getElementById('lname').focus();
			return false;
		}
		else if(document.getElementById('mobile').value.length==0)
		{
			alert('Fill mobile no field');
			document.getElementById('mobile').focus();
			return false;
		}
		else if(document.getElementById('phone').value.length==0)
		{
			alert('Fill phone no field');
			document.getElementById('phone').focus();
			return false;
		}
		else if(document.getElementById('phone').value.length==0)
		{
			alert('Fill phone no field');
			document.getElementById('phone').focus();
			return false;
		}
		else if(document.getElementById('M').checked==false && document.getElementById('F').checked==false)
		{
			alert('Pease specify the gender');
			document.getElementByName('sex').focus();
			return false;
		}
		else if(document.getElementById('address').value.length==0)
		{
			alert('Fill in the address');
			document.getElementById('address').focus();
			return false;
		}
		else if(document.getElementById('city').value.length==0)
		{
			alert('Fill in the city field');
			document.getElementById('city').focus();
			return false;
		}
		else if(document.getElementById('pcode').value.length==0)
		{
			alert('Fill in the postal code field');
			document.getElementById('pcode').focus();
			return false;
		}
		else if(!checkmail(document.getElementById('email').value))
		{
			alert('Enter the email correctly');
			document.getElementById('email').focus();
			return false;
		}
		else if(document.getElementById('username').value.length==0)
		{
			alert('Fill in the username field');
			document.getElementById('username').focus();
			return false;
		}
		else if(document.getElementById('chkavail').value=='0')
		{
			alert('This username already exists\nPlease choose another username');
			document.getElementById('username').focus();
			return false;
		}
		else if(document.getElementById('password').value.length<5)
		{
			alert('Password must be of atleast 5 chars');
			document.getElementById('password').focus();
			return false;
		}
		else if(document.getElementById('cpass').value!=document.getElementById('password').value)
		{
			alert('Confirm password field must match password field');
			document.getElementById('cpass').focus();
			return false;
		}
	}
	
	
	
	return true;
}