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.

Ads









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
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 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
job submission in cloud computing using gui representation
job submission in cloud computing using gui representation  job submission in grid computing using gui representation
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
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
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-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-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-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
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

Ads