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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


anupama
form submission
2 Answer(s)      3 years 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
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
form validation
form validation  how the form validation is done in jsf form using javaScript
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
 

 

 

DMCA.com