Hi i am doing a form validation using javascript (not jquery) just plain javascript and i can not get this to work i shall paste my html and javascript code below if anyone can get this working for me it would be great
function validate() {
var name = document.getElementById('name').value;
var address = document.getElementById('add1').value;
var city = document.getElementById('city').value;
var postcode = document.getElementById('pcode').value;
var phonenum = document.getElementById('pnum').value;
var email = document.getElementById('email').value;
var conemail = document.getElementById('conemail').value;
var pword = document.getElementById('password').value;
var conpword = document.getElementById('conpassword').value;
if (name==""){
document.getElementById("name").style.backgroundColor = "red";
document.getElementById("name").innerHTML = "You havent entered a Name"
errorCount = errorCount + 1;
if (add1==""){
document.getElementById("add1").style.backgroundColor = "red";
document.getElementById("add1").innerHTML = "You havent entered a Address"
errorCount = errorCount + 1;
if (city==""){
document.getElementById("city").style.backgroundColor = "red";
document.getElementById("city").innerHTML = "You havent entered a City"
errorCount = errorCount + 1;
if (pcode<6){
document.getElementById("pcode").style.backgroundColor = "red";
document.getElementById("pcode").innerHTML = "You havent entered a vaild Postcode"
errorCount = errorCount + 1;
if (pnum<11){
document.getElementById("pnum").style.backgroundColor = "red";
document.getElementById("pnum").innerHTML = "You havent entered a vaild Phone Number"
errorCount = errorCount + 1;
if (email.indexOf("@")==-1){
document.getElementById("Email").innerHTML = "You havent entered a vaild email"
errorCount = errorCount + 1;
if (pword==""){
document.getElementById("pword").style.backgroundColor = "red";
document.getElementById("pword").innerHTML = "You havent entered a Password"
errorCount = errorCount + 1;
}
}
}
}
}
}
}
}
function checkemail() {
if(email.value == conemail.value){
document.getElementById("conemail").innerHTML = "emails dont match"
}
}
function checkpass(){
if(pword.value == conpword.value){
document.getElementById("conemail").innerHTML = "passwords dont match"
}
}
Bookmarks