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--")

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 } <
How to validate form using Spring MVC?
How to validate form using Spring MVC?  Hi, I want to validate a form in Spring MVC using the annotation. How to validate a form in Spring MVC. I... to validate form using Spring MVC? How to use annotation for validation? Thanks
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 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
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 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
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
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
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
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
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 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
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
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
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
form values in java script - Struts
form values in java script  how to get form values in java script functions with struts1.1
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
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
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
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
Login form in Struts2 version 2.3.16
How to create Login Form in Struts2? In this video tutorial I am explaining you about the source code of the program to create the Login form in Struts2... at roseindia.net how to make a login form in Struts2. Check more Struts 2
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
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
passing values form javascript - JSP-Interview Questions
passing values form javascript  please i want to pass values from javascript function to jsp code how can i do
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
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
Need to retain the values on submiting the form - XML
Need to retain the values on submiting the form  I have created the form using XML and XSL, with textbox,checkbox,textarea and two button submit and RESET. how to retain the values in the same page on clicking submit
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 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
Form unable to hold values - Struts
Form unable to hold values  I have a form with a combo box having hasmap property. When i submit the search button and in event of an error, it does not bring the value only for this drop down box? Any ideas
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 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>
how to validate the email login
how to validate the email login  // JavaScript Document JOIN US... characters in your field. Please try again.") return false; } } return true } function validate(){ var fname=document.form.fname.value
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
HTML Code for registration form
form their is a "ADD" button behind which any desired link can be used. Once... performs the data validation on the form submitted. If it passes all the validation... basic form of the HTML from. We can use the JavaScript to validate the user
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
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
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..  
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
Displaying the values in text fields of a form from a javascript function in jsp
Displaying the values in text fields of a form from a javascript function in jsp  Hi all, I have a requirement like this, First i have... to display these values in 3 text fields of a form in the current web page. Here form
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
Calling In JavaScript Functions from HTML Form To Validate User Entered Data
Calling In JavaScript Functions from HTML Form To Validate User Entered Data  Hello, I have been working for days on my web Form assignment and editing my html to call my functions to validate the user entered data
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

Ads