Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions how to validate all form field values at once.

Have Programming Question? Ask it here!
 
 
 


Praveen Chinthala
how to validate all form field values at once.
1 Answer(s)      2 years and 6 months ago
Posted in : JavaScript Questions


how to validate all form field values at once. condition:no form field shold contain sometext("--select--")


Advertisement
View Answers

January 14, 2012 at 5:28 PM


<html>
<center>
<h2>JOIN US</h2>
</center>
<script>
function ValidPhone(aphone)
{
    var valid = "0123456789";
         if(aphone=="")
         {
    alert ("This field is required. Please enter phone number without dashes!")
         return false
         }
         if(aphone.length !=10)
         {
    alert("Invalid phone number length! Please try again.")
         return false
         }
         for (var i=0; i < aphone.length; i++)
         {
         temp = "" + aphone.substring(i, i+1);
         if (valid.indexOf(temp) == "-1")
         {
    alert("Invalid characters in your field. Please try again.")
          return false;
         }

    }
    return true
}
function validate(){
var fname=document.form.fname.value;
var lname=document.form.lname.value;
var email=document.form.email.value;
var phone=document.form.contactNo.value;
var address=document.form.address.value;
var city=document.form.city.value;
var atpos=email.indexOf("@");
var dotpos=email.lastIndexOf(".");
if(fname==""){
    alert("Please enter first name!");
    document.form.fname.focus();
    return false;
}
 if(lname==""){
    alert("Please enter last name!");
    document.form.lname.focus();
    return false;
}
 if(email==""){
    alert("Please enter email id!");
    document.form.email.focus();
    return false;
  }

if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length)
  {
  alert("Invalid Email ID");
  return false;
  }
   if(!ValidPhone(phone))
         {
         document.form.contactNo.focus()
         return false
         }
         if(address==""){
    alert("Please enter address!");
    document.form.address.focus();
    return false;
}
if(city==""){
    alert("Please enter city!");
    document.form.city.focus();
    return false;
}
return true;

}
</script>

<form name="form" method="post" action="insert.jsp" onsubmit="return validate();">
<center>
<table>
<tr><td> First Name</td><td><input type="text" name="fname"></td></tr>
<tr><td> Last Name</td><td><input type="text" name="lname"></td></tr>
<tr><td> Email</td><td><input type="text" name="email"></td></tr>
<tr><td> Contact No</td><td><input type="text" name="contactNo"></td></tr>
<tr><td> Address</td><td><input type="text" name="address"></td></tr>
<tr><td> City</td><td><input type="text" name="city"></td></tr>

<tr><td><input type="submit" value="Save"></td><td><input type="reset" value="Reset"></td></tr>
</table>
</center>
</form>
</html>


Related Tutorials/Questions & Answers:
how to validate all form field values at once.
how to validate all form field values at once.  how to validate all form field values at once. condition:no form field shold contain sometext("--select
How to validate a form - JSP-Servlet
How to validate a form   Dear Sir, I have a one jsp... want to validate a form1 i.e in form1 i have a text field for a Id values .If i submit a form without any Id values in a text field i have to get an aleert message
Advertisements
how to validate values in the dynamically created textboxes?
how to validate values in the dynamically created textboxes?  how to validate values in the dynamically created textboxes in HTML using javascript...;'; BODY.appendChild(TR1); n++; } function validate(form1) { //What to code here } <
validate text field iPhone
validate text field iPhone  i got two different UITextfield in my iPhone application for user login. Just wondering how to validate
How to validate a form in action class and forward errors to the jsp in struts?
How to validate a form in action class and forward errors to the jsp in struts?  How to validate a form in action class and forward errors to the jsp in struts
how to validate e,ail id and phne number in student form
how to validate e,ail id and phne number in student form  how to validate e,ail id and phne number in student form   Hi Friend, Visit Here Thanks
how to validate e,ail id and phne number in student form
how to validate e,ail id and phne number in student form  how to validate e,ail id and phne number in student form   Hi Friend, Visit Here Thanks
insertin form data into databse and blank all form field when click on submit button
insertin form data into databse and blank all form field when click on submit button  sir, i useing the jsp. i want insert form data into Ms-Access database when click on submit button and blank all form field after inserting
form field issue
form field issue  how to set the values in form field and form field drop down (doc 2007) using Apache poi
How do i validate form using javascript and send data to database?
How do i validate form using javascript and send data to database?  I need a "JOIN US" form that can validate using javascript and be able to connect...=="") { alert ("This field is required. Please enter phone number without dashes
how to validate e,ail id and phne number in student form
how to validate e,ail id and phne number in student form  how to validate e,ail id and phne number in student form   Hi Friend, Try the following code: <html> <script> function validate(){ var ph
the focus to the first form field
the focus to the first form field   How do I set the focus to the first form field
focus to the first form field
focus to the first form field  How do I set the focus to the first form field
focus to the first form field
focus to the first form field  How do I set the focus to the first form field
how to get a values from a multipart/form-data - JSP-Servlet
how to get a values from a multipart/form-data  Dear sir , I used your code for getting a values,i used the fllowing function... ,matter,file field values but not status and from field i am getting null
spring form field clearence
spring form field clearence  hi, I have spring form application in which i have security question and answer field for answer field validation after giving wrong format validation occurs but the field remains in that text field
form validate and perfom action immediatly
form validate and perfom action immediatly  This is ok, but what i'm looking for is whenever a user input different data his input has to validate..." for Age in a form then he needs to redirect him to some web page like
how to update values of a html form into an excel table using java servlets?
how to update values of a html form into an excel table using java servlets?  i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should
how to load values of html form into an excel table using java servlet?
how to load values of html form into an excel table using java servlet?   i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... ,update,delete database values from jtable only so i added three buttons add... of particular row is not getting added into the database whereas all other records
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... ,update,delete database values from jtable only so i added three buttons add,update... row is not getting added into the database whereas all other records are getting
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... ,update,delete database values from jtable only so i added three buttons add,update... row is not getting added into the database whereas all other records are getting
How to retrieve array values from html form to jsp?
How to retrieve array values from html form to jsp?  Hi! I am... it into jsp. Means i just want to retrieve values from html form containing array... sample code for how to retrive array values from html to jsp.   hi friend
how to pass form values from javascript of html page to jsp page
how to pass form values from javascript of html page to jsp page   ... the geocode and tries to return the lattitude and longitude .But my question is how to submit all the form values with lattitude and longitude returned from
clearing text field in spring form
clearing text field in spring form  hi, I have spring form in that i have security question dropdown field and security answer text field ,when i submitted form with errors the answers text field value should be clear, for this i
how can retrieve more than one values in text field using ajax?
how can retrieve more than one values in text field using ajax?  im using php and ajax. Problem is that i want to search seat numbers bases of batch... field so what i do? entermarks.php <div align="left"><strong>
form values in java script - Struts
form values in java script  how to get form values in java script functions with struts1.1
how to validate duplicate records in struts1
how to validate duplicate records in struts1  Hi, After submitting the form i have to validate the email id. If already exists in database i have to display an error message saying that email id already exist
how to validate duplicate records in struts1
how to validate duplicate records in struts1  Hi, After submitting the form i have to validate the email id. If already exists in database i have to display an error message saying that email id already exist
form field mapping with pdf file using java
form field mapping with pdf file using java   Hai all, I have one requirement that i have one html form.i have to map the form fields with pdf file. means, if click on text field according that perticular field .the data
How to display all the Select values from the MySQL database table in where condition= In JSP?
How to display all the Select values from the MySQL database table in where... to display all the select values from MySQL DB** only first value is displayed... the condition,but i want all the rows to be displayed in the jsp file. Plz
display all the values on next page
display all the values on next page  i am inserting values... values are inserting in the database and i am moving on another page after... when i return on first page it should display my selected values in textbox
How to revert back ServletInputStream object after reading once. - JSP-Servlet
How to revert back ServletInputStream object after reading once.  Hi All, I am trying to get parameter from request object which is multipart/form.... My Q is how can I iterate request object twice? How we can revert back
sum of all values in a column of jtable
sum of all values in a column of jtable  hey everyone, is there a code to display the sum of all values in a column of a jtable namely CARTtbl... or deleted.   Here is an example of jtable that sums up the values of two
passing the form values with image upload - JSP-Servlet
passing the form values with image upload  Hii . I want to get the solution for passing values with an image uploading form. I cant access the request values from the fields rather than image . I want to know how can cut
Pass values from form to form
Pass values from form to form       Java program to pass values from one form to another form... programmer wants that if user have logged once then until it logs out his name should
Hiding form values using ajax
Hiding form values using ajax  i am trying to show and hide form values with ajax but it's not working,but in javascript it is working.Can anyone will help me to the work in ajax please. Thanks in advance
how to perform a validation for the field
how to perform a validation for the field  hi, function checkForm...; <h2>Form Validation</h2> <script language = "Javascript... validate(){ var emailID=document.form.email; var nn
how to perform a validation for the field
how to perform a validation for the field  hi, function checkForm...; <h2>Form Validation</h2> <script language = "Javascript... validate(){ var emailID=document.form.email; var nn
dispalying arraylist values in table form
dispalying arraylist values in table form  My result is in arraylist and i want to display it in table form using iterator tag
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table as if i am... "rs.getString" in the text field also..   import java.awt.*; import
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table wth edit...;/td>"); the i am getting "rs.getString" in the text field also..  
how to get the anchor field in hidden field tag
how to get the anchor field in hidden field tag  I have a following code I need to have the value of property "emp" in a hidden field also. when i try to put the following code, I cant get the hidden tag when i see the source
Get All Keys and Values of the Properties files in Java
how to get all keys and it's values of the properties files in Java. Java provides the features to collection of all keys and values of the properties file... Get All Keys and Values of the Properties files in Java
Get All Keys and Values of the Properties files in Java
Get All Keys and Values of the Properties files in Java... to get all keys and values of the properties files in the Java. This section illustrates the way for getting all keys and corresponding values of the properties
Javascript Form validation Example
Javascript Form validation Example In this section we will discuss about how to validate your application form in javascript. In many applications data... inserted is correct or not you will be required to validate your form. Here I
inserting all the values in a html table column
inserting all the values in a html table column  strong text hai everyone, i'm a fresher to servlet i need to know that, how can i insert all the values in a html table column into a database. Thanks in advance
how to validate national ID number
how to validate national ID number  hey guys, plz send me a code how to vlaidate national ID number using jtextfield. in ID num thers 9 numbers +V.the V letter is included at the end of the numbers. ex:123456789V i don knw how
Ajax validation in struts2.
Ajax validation in struts2. In this section, you will see how to validate fields  of form in struts2.  1-index.jsp <html> <head>..."><tr><td> <s:form action="
How to refresh Client only once by sending setHeader ("refresh" ,??? )
How to refresh Client only once by sending setHeader ("refresh" ,??? )  How can i send response from JSP that will make my client page to be refreshed ?? I just want to refresh my client page only once....! Not periodically
Advertisements
 

 

 

DMCA.com