form submission

form submission

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.

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
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
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
form
form   Can I prevent a form from being submitted again
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
. Our articles submission form will collect the information like author... Article Submission Format - Format for Publishing Articles... submission guidelines detailed in this page will help you better in submitting
ModuleNotFoundError: No module named 'arunwagle-submission-intake-utils'
ModuleNotFoundError: No module named 'arunwagle-submission-intake-utils' ...: ModuleNotFoundError: No module named 'arunwagle-submission-intake-utils' How to remove the ModuleNotFoundError: No module named 'arunwagle-submission-intake-utils'
ModuleNotFoundError: No module named 'arxiv-submission-events'
ModuleNotFoundError: No module named 'arxiv-submission-events'  Hi...: No module named 'arxiv-submission-events' How to remove the ModuleNotFoundError: No module named 'arxiv-submission-events' error? Thanks   
ModuleNotFoundError: No module named 'arxiv-submission-events'
ModuleNotFoundError: No module named 'arxiv-submission-events'  Hi...: No module named 'arxiv-submission-events' How to remove the ModuleNotFoundError: No module named 'arxiv-submission-events' error? Thanks   
ModuleNotFoundError: No module named 'arxiv-submission-events'
ModuleNotFoundError: No module named 'arxiv-submission-events'  Hi...: No module named 'arxiv-submission-events' How to remove the ModuleNotFoundError: No module named 'arxiv-submission-events' error? Thanks   
ModuleNotFoundError: No module named 'deadline-docker-submission'
ModuleNotFoundError: No module named 'deadline-docker-submission'  Hi...: No module named 'deadline-docker-submission' How to remove the ModuleNotFoundError: No module named 'deadline-docker-submission' error? Thanks
ModuleNotFoundError: No module named 'django-remote-submission'
ModuleNotFoundError: No module named 'django-remote-submission'  Hi...: No module named 'django-remote-submission' How to remove the ModuleNotFoundError: No module named 'django-remote-submission' error? Thanks  
ModuleNotFoundError: No module named 'django-remote-submission'
ModuleNotFoundError: No module named 'django-remote-submission'  Hi...: No module named 'django-remote-submission' How to remove the ModuleNotFoundError: No module named 'django-remote-submission' error? Thanks  
ModuleNotFoundError: No module named 'django-unique-submission'
ModuleNotFoundError: No module named 'django-unique-submission'  Hi...: No module named 'django-unique-submission' How to remove the ModuleNotFoundError: No module named 'django-unique-submission' error? Thanks  
ModuleNotFoundError: No module named 'my_first_submission_test'
ModuleNotFoundError: No module named 'my_first_submission_test'  Hi...: No module named 'my_first_submission_test' How to remove the ModuleNotFoundError: No module named 'my_first_submission_test' error? Thanks  
ModuleNotFoundError: No module named 'my_first_submission_test'
ModuleNotFoundError: No module named 'my_first_submission_test'  Hi...: No module named 'my_first_submission_test' How to remove the ModuleNotFoundError: No module named 'my_first_submission_test' error? Thanks  
ModuleNotFoundError: No module named 'arunwagle-submission-intake-utils'
ModuleNotFoundError: No module named 'arunwagle-submission-intake-utils' ...: ModuleNotFoundError: No module named 'arunwagle-submission-intake-utils' How to remove the ModuleNotFoundError: No module named 'arunwagle-submission-intake-utils'
ModuleNotFoundError: No module named 'arxiv-submission-core'
ModuleNotFoundError: No module named 'arxiv-submission-core'  Hi...: No module named 'arxiv-submission-core' How to remove the ModuleNotFoundError: No module named 'arxiv-submission-core' error? Thanks   Hi
ModuleNotFoundError: No module named 'arxiv-submission-events'
ModuleNotFoundError: No module named 'arxiv-submission-events'  Hi...: No module named 'arxiv-submission-events' How to remove the ModuleNotFoundError: No module named 'arxiv-submission-events' error? Thanks   
ModuleNotFoundError: No module named 'deadline-docker-submission'
ModuleNotFoundError: No module named 'deadline-docker-submission'  Hi...: No module named 'deadline-docker-submission' How to remove the ModuleNotFoundError: No module named 'deadline-docker-submission' error? Thanks
ModuleNotFoundError: No module named 'django-remote-submission'
ModuleNotFoundError: No module named 'django-remote-submission'  Hi...: No module named 'django-remote-submission' How to remove the ModuleNotFoundError: No module named 'django-remote-submission' error? Thanks  
ModuleNotFoundError: No module named 'django-unique-submission'
ModuleNotFoundError: No module named 'django-unique-submission'  Hi...: No module named 'django-unique-submission' How to remove the ModuleNotFoundError: No module named 'django-unique-submission' error? Thanks  
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... Hierarchical tree of submission targets configured by an easy-to-understand
form validation
form validation  how the form validation is done in jsf form using javaScript
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
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
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
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
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
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

Ads