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




Have Programming Question? Ask it here!
 
 
 


anupama
form submission
2 Answer(s)      2 years and 10 months ago
Posted in : JavaScript Questions


I have two pairs of textboxes...( so in total 4)...if both the pairs are empty, the values in the corresponding textboxes should not go to the database...otherwise if either or both are filled, they can go to the database.


Advertisement
View Answers

September 12, 2011 at 3:45 PM


<html>
<script>
function validate(){
var v1=document.form.text1.value;
var v2=document.form.text2.value;
var v3=document.form.text3.value;
var v4=document.form.text4.value;
if(v1==""){
alert("Enter text1 value!");
return false;
}
if(v2==""){
alert("Enter text2 value!");
return false;
}
if(v3==""){
alert("Enter text3 value!");
return false;
}
if(v4==""){
alert("Enter text4 value!");
return false;
}
return true;
}
</script>
<form name="form" method="post" onsubmit="return validate();">
<input type="text" name="text1"><br>
<input type="text" name="text2"><br>
<input type="text" name="text3"><br>
<input type="text" name="text4"><br>
<input type="submit" value="submit">
</form>
</html>


September 12, 2011 at 4:34 PM


Thnx for the solution...but I want a different solution. Let me explain the case w.r.t your answer. v1,v2 are pair 1 and v3,v4 are pair 2.I need to give an error prompt if none of them are filled. If v1,v2 are filled or v3,v4 are filled or all the fields are filled, it should go to database. I think I was not clear in my question. So, v1 and v2 are considered as one and similarly v3 and v4 are considered as one.



Related Tutorials/Questions & Answers:
form submission
form submission  I have two pairs of textboxes...( so in total 4...("Enter text4 value!"); return false; } return true; } </script> <form name="form" method="post" onsubmit="return validate();"> <input type="text
javascript form submission
javascript form submission  how can apply validation when doing submission like following <html> <script type="text/javascript...(); } </script> <form id="myform" action="submit-form.php
Advertisements
How to use struts2 grid with form submission
How to use struts2 grid with form submission  Hello, I've already searched on Stackoverflow with no luck; I want to make one filter form... having all data. I tried setting target of form and , but it didnt work
job submission in cloud computing
job submission in cloud computing  job submission in cloud computing
job submission in cloud computing
job submission in cloud computing  job submission in grid computing
job submission in cloud computing
job submission in cloud computing  job submission in grid computing using gui representation
Swing Problem on submission of button
Swing Problem on submission of button  How to close current frame (Frame1) and open a new frame (Frame2) already created and pass the data to frame2 from frame1 on the clicking of button in swing
HTML Post Form
HTML Post Form       The HTML process the submission of form in two different ways. In HTML, the method is declared inside a FORM element. The form method is  used
Manual Vs Automated web submission
Manual Vs Automated web submission In this section we will see the benefits of Manual web submission over automated web submission. Search engines... or use the automated web submission software. Now a days search engines prefer
Articles - Articles Submission Guidelines
Articles - Articles Submission Guidelines       In this Articles Submission Guide you will learn how... on the internet. Article writing and submission to free article directory is one
job submission in cloud computing using gui representation
job submission in cloud computing using gui representation  job submission in grid computing using gui representation
Article Submission Format - Format for Publishing Articles
articles submission form will collect the information like author and the article... Article Submission Format - Format for Publishing Articles... submission guidelines detailed in this page will help you better in submitting
form
form   Can I prevent a form from being submitted again
Two forms submission to one Action Class in Struts2.0
Two forms submission to one Action Class in Struts2.0  Hi, I have two forms.I want to submit two forms with only one submit button to the same action, same method. How can i get this. Please reply me
Submit Articles Free - Free Resources For Articles Submission
Submit Articles Free - Free Resources For Articles Submission... for articles submission. Articles submission to the free articles... of the best free articles submission website. Submit Your Articles
Web-CAT Electronic Submission Plug-in
Web-CAT Electronic Submission Plug-in       The electronic submission plug... be added via extension points Hierarchical tree of submission
Manual Submission to Search Engines. Hand Submit Website URL Submission to Major Search Engines
will then submit your site to major search engine every month and the submission... submission guaranteed  Getting more visitors  Increasing online
form validation
form validation  how the form validation is done in jsf form using javaScript
Business Benefits Of Companies Concerned With SEO copywriting And Submission Services on the Internet - SEO Article
and Submission Services on the Internet Copywriting for search engines helps you... Copywriting and Submission Services: SEO copywriting involves adding extra features... recommend strategically placing nearly 250 keywords in your copy. Submission
i want to select a multiple value of check box by using onclick or onchange event without using from submission
i want to select a multiple value of check box by using onclick or onchange event without using from submission   i have 4 check box name 1)profile 2)commercial 3)motion 4)personal and 4 radio button name 1)500-1000 2
print a form of *
print a form of *   * *** ***** ******* ********* ******* ***** *** *   Post the format properly
Multipage form
Multipage form  I have a multipage form in php with 2 pages wnhen i submit the form data from both the pages should go in database how should i pass teh data from 1st page to 2nd page and then put the entire form data in mysql
jsp form
jsp form  hi sir, one got one got in jsp form after entering the data into the form the data is not saving in the database i will send you code of two forms if dnt understand my problem
submit a form
submit a form  How can we submit a form without a submit button
Form handling
Form handling  I created a spring project. I created a jsp...;form:form name="loginForm" modelAttribute="loginForm" method="get"> <...;/td> <td> <form:input path="username"/>
Form Validation
Form Validation  Java script validation for checking special characters and white spaces and give an alert.Please help me urgent Thanks in advance
<form id=
form id  sir, <form id="reg1" action="../UploadingCtrl" method="post" enctype="multipart/form-data" name="form1"> this action page can't get String tp = request.getParameter("indegrates"). i wrote article upload
<form id=
form id  sir, <form id="reg1" action="../UploadingCtrl" method="post" enctype="multipart/form-data" name="form1"> this action page can't get String tp = request.getParameter("indegrates"). i wrote article upload
Form validation
Form validation  Hi Everyone Can someone assist me with a complete code to validate a form. e.g where the user must insert an ID number it should check if the user entered the correct data and within a valid range. This must
PHP form
PHP form  Hi Sir/Madam, I am developing an attendance form using php, which displays the name and ID of a Employees which are fetched from Db and I... form and update them to respective coloumn... Please any one help mo out please
Employee form
Employee form  In employee form emp Id id after any data iserted is incremented for oher data insertion. insert, delete, update buttons when we cleak the select buttoun then the created table data iserted automaticaly
other form
other form  Can I write this code in other form: if (quantity>=5) { System.out.println("Congrats!! You get a discount of 5%."); } else { System.out.println("you can avail a discount of 5% when you make a purchase of 5 items
struts form
struts form  Hi, This is Rajesh.I'm creating struts form in jsp.i have two textboxes in my jsp.During Jsp page loading focus will automatically should come to second textbox(That means during page loading cursor automatically
login form
login form  sir my next form consists logout button when i click on it it showing login form but next form window is not closing but the components prepsent in that form are getting clearedup using frameobject.setVisible(false
login form
login form  sir my next form consists logout button when i click on it it showing login form but next form window is not closing but the components prepsent in that form are getting clearedup using frameobject.setVisible(false
Login Form
of +,on clicking which a login form appears. Only the middle column is different
Login Form
of +,on clicking which a login form appears. Only the middle column is different
jsp form
jsp form  hai... GoodEvening I have one doubt on jsp.please wil u clarify it. how to move one jsp form to another jsp form with out using forward...)form1.jsp: <html> <form method="post" action="form2.jsp"> <table>
form validation
form validation  <form name="form" method="post" action="process.php" onsubmit="return validate(); "> <table align="center" border="1px" bgcolor="orange" > <tr><td>username:</td><
about form
about form  how to dynamically increase the textbox in the 2nd form when i gave any value in textbox of form1 . if i gave 5 in the textbox of form1 , totally 5textbox have to be created in form2.   import javax.swing.
dynamic form
dynamic form  I need to make a dynamic form using php, for example, i... button wich once clicked we have a new list created on the same form. Thank you...); } } </script> <form method="post" action="" name="form1"> <
Dynamic form
Dynamic form  I need to make a dynamic form using jsp for example, i will need a list of items which when we select one option another list... clicked we have a new list created on the same form. Thanks for your help  
jsp form
jsp form  hi i have one excuted jsp form.and in that the data should be dispaly on another jsp form.please help me thanks in advance   Hi Friend, Try this: 1)form1.jsp: <html> <form method="post" action
registration form
="center" border=0&gt; &lt;form name="f1" action="CreateUser
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation
Get Method of the Form In JSP
; Output for the example: Output after submission the form: Download the JSP... Get Method of the Form In JSP     ... of the form in JSP. The HTTP get method sends data to the server. In your JSP
The form tag
In this tutorial, you will learn about Spring form tag
form field issue
form field issue  how to set the values in form field and form field drop down (doc 2007) using Apache poi
create a form using struts
create a form using struts  How can I create a form for inputting text and uploading image using struts
HTML Form data into .CSV?
HTML Form data into .CSV?  how to store data from html form to csvfile in java
 

 

 

DMCA.com