Click here to Skip to main content
15,923,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
It is getting error in console please give me help.

It is a registration form with JavaScript validation.In this all the inputs are mandatory and email address entered should be in correct format.Also, the values entered in the password and confirm password should be same.And also after validating using javascript, display proper error message in text box where there is an error.It is not displaying error message too.

What I have tried:

.html file



<title>Registration Form..






Registration Form




Registration Form



  • First Name:

  • Last Name:

  • e-mail id:

  • User Id:

  • Password:

  • Confirm Password:










// here is .css file
li{
list-style:none;
padding: 5px;
margin: 10px;
}
.outerContainer {
border: 1px solid;
width: 500px;
height: 550px;
margin: 10px auto;
background:#fffccc;
background:img;
}
.footer,
.header {
text-align: center;
border: 1px solid;
margin: 5px;
padding: 5px;
background:#0000ff;

}
.footer {
font-size: 11px;
clear:both;
font-style:Mistral;

}

.innerContainer{
border: 1px solid;
text-align: center;
margin: 5px;
height:400;
overflow: scroll;

padding: 5px;
background-image:url("https://image.freepik.com/free-vector/blue-abstract-background-with-lights_1048-3309.jpg");


}
form{
background:#ffccaa;
display-block:center;
}

h5{
text-align:center;
color:#ff23ff;

}
label{
color: #464646;
text-shadow: 0 1px 0 #fff;
font-size: 14px;
font-weight: bold;
}
span{
color:#ff0000;
}
// here is .js file

var divs=new Array();
divs[0]="errFirst";
divs[1]="errLast";
divs[2]="errEmail";
divs[3]="errUid";
divs[4]="errPwd";
divs[5]="errConfirm";

function validate(){
var inputs=new Array();
inputs[0]=document.getElementById('first').value;
inputs[1]=document.getElementById('last').value;
inputs[2]=document.getElementById('email').value;
inputs[3]=document.getElementById('uid').value;
inputs[4]=document.getElementById('pwd').value;
inputs[5]=document.getElementById('confirm').value;
var errors= new Array();
errors[0]="Please enter your First name!";
errors[1]="Please enter your Last name!";
errors[2]="Please enter your e-mail-id!";
errors[3]="Please enter your User Id!";
errors[4]="Please enter your Password!";
errors[5]="Please enter your Confirm Password!";
for(i in inputs){

var errMsg=errors[i];
var divMsg=divs[i];
if(inputs[i]=="")

document.getElementById(divMsg).innerHTML=errMsg;

else if(i==2){
var atpos=inputs[i].indexOf("@");
vat dotpos=inputs[i].lastIndexOf(".");
if(atpos<1 || dotpos<atpos+2 || dotpos+2>= inputs[i].length)
document.getElementById('errEmail').innerHTML="Enter Valid e-mail adderss!!";
else
document.getElementById(divMsg).innerHTML="OK!";
}else if(i==5){
var ff=document.getElementById('pwd').value;
var ss=document.getElementById('confirm').value;
if(ss!=ff)
document.getElementById("errConfirm").innerHTML="Your password doesnot match..!!";
else
document.getElementById("divMsg").innerHTML="OK!";
}else
document.getElementById(divMsg).innerHTML="OK!";
}

}
Posted
Updated 2-Mar-17 22:07pm

1 solution

This is plain messy code dump that does not make sense. We have no access to either your computer or screen. Learn to debug it yourself using JavaScript Debugging[^]. If you have any doubts using HTML and JavaScript, always consult W3Schools Online Web Tutorials[^]. In fact, HTML5 form come with built-in validations, learn HTML5 Form Validation[^]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900