The JavaScript code is given below. Check it and use all the validation checks, so that the program will have the form(structure) like in the given picture. Form Validation


The JavaScript code is given below. Check it and use all the validation checks, so that the program will have the form(structure) like in the given picture.






 Form Validation
 

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

  function validate()
  {
   var inputs=new Array();
   inputs[0]=document.getElementByld('first').value;
   inputs[1]=document.getElementByld('last').value;
   inputs[2]=document.getElementByld('email').value;
   inputs[3]=document.getElementByld('uid').value;
   inputs[4]=document.getElementByld('password').value;
   inputs[5]=document.getElementByld('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 email!";
   errors[3]="Please enter your user id!";
   errors[4]="Please enter your password!";
   errors[5]="Please confirm your password!";

  for (i in inputs)
   {
    var errMessage=errors[i];
    var div=divs[i];
    if(inputs[i]=="")
       document.getElementByld(div).innerHTML=errMessage;
    else if (i==2)
     {
      var atpos=inputs[i].indexOf("@");
      var dotpos=inputs[i].lastIndexOf(".");
      if (atpos<1 ||="" dotpos<atpos+2="" ||="" dotpos+2="">=inputs[i].length)
         document.getElementByld('errEmail').innerHTML="Enter a valid email address!";
      else
         document.getElementByld(div).innerHTML="OK!";
      }
      else if (i==5)
      {
       var first=document.getElementByld('password').value;
       var second=document.getElementByld('confirm').value;

        if (second!=first)
           document.getElementByld('errConfirm').innerHTML="Your passwords don't match!";
        else
           document.getElementByld(div).innerHTML="OK!";
       }
       else
         document.getElementByld(div).innerHTML="OK!";
      }
     }

   function finalValidate()
   {
    var count=0;

    for(i=0;i<>
     {
      var div=divs[i];

      if(document.getElementByld(div).innerHTML=="OK!")
      count=count+1;
     }
     if(count==6)
       document.getElementByld("errFinal").innerHTML="All the data entered is correct!!!";
    }
















































































































First Name:



Last Name:



Email:



User Id:



Password:



Confirm Password:













First Name:<br>Last Name:<br>Email:<br>User Id:<br>Password:<br>Confirm Password:<br>Create<br>] Please enter your first name!<br>|Please enter your last name!<br>| Please enter your email!<br>|Please enter your user id!<br>| Please enter your password!<br>| Please confirm your password!<br>First Name:<br>Last Name:<br>Email:<br>User Id:<br>Password:<br>Confirm Password:<br>Create<br>First Name:<br>Ayesha<br>OK!<br>Lara<br>OK!<br>OK!<br>Last Name:<br>Email:<br>ays@yahoo.com<br>User Id:<br>12345<br>OK!<br>Password:<br>OK!<br>Confirm Password:<br>OK!<br>....<br>Create<br>All the data you entered is correct!!!<br>

Extracted text: First Name: Last Name: Email: User Id: Password: Confirm Password: Create ] Please enter your first name! |Please enter your last name! | Please enter your email! |Please enter your user id! | Please enter your password! | Please confirm your password! First Name: Last Name: Email: User Id: Password: Confirm Password: Create First Name: Ayesha OK! Lara OK! OK! Last Name: Email: [email protected] User Id: 12345 OK! Password: OK! Confirm Password: OK! .... Create All the data you entered is correct!!!

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here