this is my javascript code to display all errors in one single alert box, but i am not getting this,please help me to sort out this?

this is my javascript code to display all errors in one single alert box, but i am not getting this,please help me to sort out this?

<html>
    <script language = "JavaScript">
function checkName(text) {
if(isNaN(text)){ return 1;}
else{alert("Please enter a valid name. The only charachters accepted are A - Z and a - z");return 0;}
}
function checkAddress(text) {
if(isNaN(text)){ return 1;}
else{alert("Please enter a valid address. The only charachters accepted are A - Z and a - z");return 0;}
}


function validate(){
   var Errortext="";

    var emailID=document.form.email;
        var nn1=document.form.fname;
        var nn2=document.form.lname;
        var add=document.form.address;
        var gen=document.form.radios;
        var mobile=document.form.mobilenumber;
        var city=document.form.cityname;
        var state=document.form.statename;
        var zip=document.form.zip1;
        var password=document.form.pass;
        var cpassword=document.form.cpass;

      if(nn1.value == ""){
      Errortext+="Please enter first name\n";

    nn1.focus();
    return false;
      }
     else if (checkName(nn1.value)==false){
      nn1.value=""
      nn1.focus()
      return false
      }

      else if (nn2.value == ""){
      Errortext+="please enter your name\n";

    nn2.focus();
    return false;
      }
      if (checkName(nn2.value)==false){
      nn2.value=""
      nn2.focus()
      return false
      }
       else if ( (gen[0].checked == false ) && ( gen[1].checked == false ) ){
    Errortext+="please check your gender: Female or Male\n";
    gen[0].focus();
    return false;
    }
      else if ((emailID.value == "" ||emailID.value.indexOf('@', 0) == -1) ||emailID.value.indexOf('.') == -1){
      Errortext+="please enter proper email id\n";
      emailID.focus();
      return false;
      }
    else if(mobile.value=="")
    {
    Errortext+="please Enter the Contact Number\n";
    mobile.focus();
    return false;
    }
    else if(isNaN(mobile.value)||(mobile.value.length!=10))
    {
    Errortext+="Enter the valid Mobile Number\n";
    mobile.focus()
    return false
    }


      if(password.value==""){
     Errortext+="password should be filled\n";
      password.focus();
      return false;
      }
      if(cpassword.value==""){
      Errortext+="confirm password should be filled\n";
      cpassword.focus()
      return false
      }
      if((cpassword.value=="")||(password.value!=cpassword.value)){

    Errortext+="Please enter Password and confirm password and both should be same\n";
     cpassword.focus()
      return false

  }

  if (add.value == ""){
    Errortext+="Please enter address\n"; 
    add.focus();
    return false;
    }
    if (checkAddress(document.form.address.value)==false){
      address.value=""
      address.focus()
      return false
      }
  if(city.value==""){
      Errortext+="please enter your city\n";
      city.focus();
      return false;
  }    
  if(state.value==""){
      Errortext+="please enter your state\n";

      state.focus();
      return false;
  }   
  if( zip.value == "" || isNaN(zip.value ) ||zip.value.length != 6 ){
        Errortext+= "Please provide a zip in the format ######.\n";
        zip.focus();
        return false;
        }
   if(Errortext!=""){
       alert( Errortext) 
    return false; 
   }


    return true

}
    </script>
    <form name="form"  onSubmit="return validate()">
        <pre>
    First Name<input type="text" name="fname" id="fn" size="30">
    Last Name<input type="text" name="lname" id="ln" size="30">
    Gender<input type="radio" name="radios" value="male">Male <input type="radio" name="radios" value="Female">Female
    Enter an Email Address<input type="text" name="email" size="30">
    Mobile Number<input type="text" name="mobilenumber">
    Password<input type="password" name="pass">
    Confirm Password<input type="password" name="cpass">
    Address1<input type="text" name="address">
    Address2<input type="text" name="add2">
    Address3<input type="text" name="add3">
    City<input type="text" name="cityname">
    State<input type="text" name="statename">
    ZIP<input type="text" name="zip1">
    <input type="submit" name="Submit" value="Submit">
        </pre></form>

</html>
View Answers









Related Tutorials/Questions & Answers:
this is my javascript code and i am not understanding the mistake in this,please help me?
I need help on my Java code.... please please help me out!?
Advertisements
autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me
i am Getting Some errors in Struts - Struts
Please help me out
Please help me to modify my java code from php code
Please help me to modify my java code from php code
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?
I really need help with this assignment question Please help me out Please
please please i wanna insertion sort program find calendar to array value (1000,5000,10000), please help me
verify the code and give me the code with out errors
I want to update the multiple values of database depending on checkbox..? Please help me out..
Please help me fix this code - MobileApplications
Can any one please help me in this ,,,,,,, need java code for this ,,,,please anyone
Help me please with my final homework
Not sure whats wrong with my code HELP PLEASE?!?!
this is my file upload page, here i am not getting tags input field value to my servlet,please suggest a solution?
JavaScript display variable in alert
please help me solve this problem when i am create database connection using servlecontext
I am getting Undefined in Text Box Very Urgent - JSP-Servlet
Display JSP selected listbox and checkbox in xml-please help me
I am trying to develop a Image Sliding application but unfortunately its not working... Can any one help me in this
help me plz:-Merge multiple jasper files into Single one
Getting Exception on UseDefinedException sample program - Please help me how to resolve
please help me to write a code for this program
please help me to write a code for this program
i want to find the byte code of a image file ... for my project..plz if anybody help me for java coding i will grateful..
please help me to give code - Java Beginners
please help me to give code - Java Beginners
PLEASE HELP WITH MY JAVA
please help me to give code - Java Beginners
please help me.
please help me.
please help me to give code - Java Beginners
please help me to give code - Java Beginners
Begineer Help Help Please Thanks A million ) I am using Jcreator
Please help me.
I am having problem with configuring Hibernate sessionfactory. Please Help
PLZ HELP ME. i need php code.
I want to Transfer only 1/3rd of contents from one folder to other but my code is transferring all contents
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx
please send me javascript validation code - Java Beginners
please help me.
i am unable to identify the error in my code
i am unable to identify the error in my code
inheritance....please help me friends...!!!... this is important project that i have to do it..
urgent...pleAse help me.....please!
Please help me to write a code for add contacts to groups in a website?

Ads