Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function checkForm()
- {
- name = document.getElementById("name").value;
- idnum = document.getElementById("idnum").value;
- phone = document.getElementById("phone").value;
- email = document.getElementById("email").value;
- username = document.getElementById("username").value;
- password = document.getElementById("password").value;
- var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.((com)|(net)|(my))$/;
- var valnum = /^(6)+(0)+([0-9]{1,2})+\-([0-9]{7,8})$/;
- if(name=="")
- {
- hideAllErrors();
- document.getElementById("nameError").style.display = "inline";
- return false;
- }
- if(idnum=="")
- {
- hideAllErrors();
- document.getElementById("idError").style.display = "inline";
- return false;
- }
- if(phone=="")
- {
- hideAllErrors();
- document.getElementById("phoneError").style.display = "inline";
- return false;
- }
- if(valnum.test(phone)== false)
- {
- hideAllErrors();
- document.getElementById("phoneNotValid").style.display = "inline";
- return false;
- }
- if(email=="")
- {
- hideAllErrors();
- document.getElementById("emailError").style.display = "inline";
- return false;
- }
- if(reg.test(email)== true)
- {
- for(i=0; i<email.length; i++)
- {
- if(email.charAt(i) == email.charAt(i-1))
- {
- hideAllErrors();
- document.getElementById("emailNotValid").style.display = "inline";
- return false;
- }
- }
- }
- if(reg.test(email)== false)
- {
- hideAllErrors();
- document.getElementById("emailNotValid").style.display = "inline";
- return false;
- }
- if(username=="")
- {
- hideAllErrors();
- document.getElementById("usernameError").style.display = "inline";
- return false;
- }
- if(username.length<6)
- {
- hideAllErrors();
- document.getElementById("usernameNotValid").style.display = "inline";
- return false;
- }
- if(username.length>5)
- {
- for(i=0; i<username.length; i++)
- {
- if(username.charAt(i) == username.charAt(i-1))
- {
- hideAllErrors();
- document.getElementById("usernameNotValid").style.display = "inline";
- return false;
- }
- }
- }
- if(password=="")
- {
- hideAllErrors();
- document.getElementById("passwordError").style.display = "inline";
- return false;
- }
- if(password.length<6)
- {
- hideAllErrors();
- document.getElementById("passwordNotValid").style.display = "inline";
- return false;
- }
- if(password.length>5)
- {
- for(i=0; i<password.length; i++)
- {
- if(password.charAt(i) == password.charAt(i-1))
- {
- hideAllErrors();
- document.getElementById("passwordNotValid").style.display = "inline";
- return false;
- }
- }
- }
- return true;
- }
- function checkName()
- {
- name = document.getElementById("name").value;
- if(name=="")
- {
- hideAllErrors();
- document.getElementById("nameError").style.display = "inline";
- return false;
- }
- return true;
- }
- function checkId()
- {
- idnum = document.getElementById("idnum").value;
- if(idnum=="")
- {
- hideAllErrors();
- document.getElementById("idError").style.display = "inline";
- return false;
- }
- return true;
- }
- function checkPhone()
- {
- phone = document.getElementById("phone").value;
- var valnum = /^(6)+(0)+([0-9]{1,2})+\-([0-9]{7,8})$/;
- if(phone=="")
- {
- hideAllErrors();
- document.getElementById("phoneError").style.display = "inline";
- return false;
- }
- if(valnum.test(phone)== false)
- {
- hideAllErrors();
- document.getElementById("phoneNotValid").style.display = "inline";
- return false;
- }
- return true;
- }
- function checkEmail()
- {
- email = document.getElementById("email").value;
- var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.((com)|(net)|(my))$/
- if(email=="")
- {
- hideAllErrors();
- document.getElementById("emailError").style.display = "inline";
- return false;
- }
- if(reg.test(email)== true)
- {
- for(i=0; i<email.length; i++)
- {
- if(email.charAt(i) == email.charAt(i-1))
- {
- hideAllErrors();
- document.getElementById("emailNotValid").style.display = "inline";
- return false;
- }
- }
- }
- if(reg.test(email)== false)
- {
- hideAllErrors();
- document.getElementById("emailNotValid").style.display = "inline";
- return false;
- }
- return true;
- }
- function checkUsername()
- {
- username = document.getElementById("username").value;
- if(username=="")
- {
- hideAllErrors();
- document.getElementById("usernameError").style.display = "inline";
- return false;
- }
- if(username.length<6)
- {
- hideAllErrors();
- document.getElementById("usernameNotValid").style.display = "inline";
- return false;
- }
- if(username.length>5)
- {
- for(i=0; i<username.length; i++)
- {
- if(username.charAt(i) == username.charAt(i-1))
- {
- hideAllErrors();
- document.getElementById("usernameNotValid").style.display = "inline";
- return false;
- }
- }
- }
- return true;
- }
- function checkPassword()
- {
- password = document.getElementById("password").value;
- if(password=="")
- {
- hideAllErrors();
- document.getElementById("passwordError").style.display = "inline";
- return false;
- }
- if(password.length<6)
- {
- hideAllErrors();
- document.getElementById("passwordNotValid").style.display = "inline";
- return false;
- }
- if(password.length>5)
- {
- for(i=0; i<password.length; i++)
- {
- if(password.charAt(i) == password.charAt(i-1))
- {
- hideAllErrors();
- document.getElementById("passwordNotValid").style.display = "inline";
- return false;
- }
- }
- }
- return true;
- }
- function hideAllErrors()
- {
- document.getElementById("nameError").style.display="none"
- document.getElementById("idError").style.display="none"
- document.getElementById("phoneError").style.display="none"
- document.getElementById("phoneNotValid").style.display="none"
- document.getElementById("emailError").style.display="none"
- document.getElementById("emailNotValid").style.display="none"
- document.getElementById("usernameError").style.display="none"
- document.getElementById("usernameNotValid").style.display="none"
- document.getElementById("passwordError").style.display="none"
- document.getElementById("passwordNotValid").style.display="none"
- }
Add Comment
Please, Sign In to add comment