How to validate a form

Ads

 
 
 

Share on Google+Share on Google+

harini
How to validate a form
1 Answer(s)      6 years and 11 months ago
Posted in : JSP-Servlet
Dear Sir,
I have a one jsp ,in that i have a 2 forms

///One form1 as follows
<form method="post" onsubmit="return IsEmpty(this);">
<center>
<table>
<tr>
<td><b>Id</b><input type="text" name="idvalue" value="<%=sessId %>" ></td>
<td><b>Subject</b><input type="text" name="subject" value="<%=sessSub %>"></td>
<td><b>Status</b><input type="text" name="statusvalue" value="<%=sessStat %>"></td>
<td><input type="submit" value="Search"></td>
</tr>
</table>
</center>
</form>

/// Another form2 is as follows

<form name="mesdetails" method="post" action="../mesdetails.do"><input
type="hidden" name="act" value="" />
<table class="ContentTable" border="4" bordercolor="#660066"
align="center" cellspacing="0" cellpadding="4.5" style="width: 770px"
id="results">

And soon ...

Now i 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 so how to do this sir please help me..

Thanks and Regards
Harini Veerapur.
Ads
View Answers

June 22, 2010 at 11:12 AM


Hi Friend,

Try the following code:

<script>
function validate(){
var id=document.form1.idvalue.value;
if (id == ""){
alert("Please enter id.");
form1.idvalue.focus();
return false;
}
return true;
}
</script>
<form name="form1" method="post" action="enter.jsp" onsubmit="return validate();">
<table>
<tr><td>Id</td><td><input type="text" name="idvalue" ></td></tr>
<tr><td>Subject</td><td><input type="text" name="subject" ></td></tr>
<tr><td>Status</td><td><input type="text" name="statusvalue" ></td></tr>
<tr><td><input type="submit" value="Search"></td>
</tr>
</table>
</form>

<form name="mesdetails" method="post" action="../mesdetails.do"><input
type="hidden" name="act" value="" />
<table class="ContentTable" border="4" bordercolor="#660066"
align="center" cellspacing="0" cellpadding="4.5" style="width: 770px"
id="results">
</table>
</form>

Thanks

Ads









Related Tutorials/Questions & Answers:
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
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
Advertisements
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
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
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 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 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....") return false; } } return true } function validate(){ var
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
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
how to validate the email login
how to validate the email login  // JavaScript Document JOIN US < aphone.length; i++) { temp = "" + aphone.substring(i, i...; } } return true } function validate(){ var fname=document.form.fname.value
how to validate national ID number
how to validate national ID number  hey guys, plz send me a code how to vlaidate national ID number using jtextfield. in ID num thers 9 numbers +V.the V letter is included at the end of the numbers. ex:123456789V i don knw how
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
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
Validate
Validate   hi all..im a beginner java and i need some help from u guys.. Its about validate. My HR request BF = 'brought forward', leave cannot apply date greater than 31/03 of particular year. So, if the user apply the date
VALIDATE
one application inthis application by using jsp file to crate a form by using that form i can enter the data it will connect to business logic and the inserted... have some problem that is i want see the previously enterd data in a form page
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 the telephone number without using jquery in html with javascript
how to validate the telephone number without using jquery in html with javascript  how to validate the telephone number without using jquery in html with javascript
How to create form in Swings
How to create form in Swings  How to create registration, login and question form in Java Swing?   Creating different forms in Java Swing - Examples how to create registration form in swing swing login form example
How to reset a form in jQuery?
How to reset a form in jQuery?  Hi, I have a form where I am using jQuery. I want to reset the form. How I can reset the form grammatically?   Hi, You can use following code: $("#MyFomrName").reset(); Thanks
How to Validate dynamically created text box in HTML using Javascript
How to Validate dynamically created text box in HTML using Javascript ... in IE but not in fire fox and chrome. how to make this to work in all browsers. And also how to validate the text boxes created dynamically. <html>
long validate
long validate  How to validate long type
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations  <[email protected] import="java.sql.SQLException"%> <[email protected] import...=xmlhttp.responseText; } } xmlhttp.open("GET","Ajax_Prepaid_GSM_Verification?q="+str
How to design a form using java?
How to design a form using java?  Please help in designing of form using java for my project
swings:how to link from one form to another form
swings:how to link from one form to another form  how to link from one form to another form
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...","Ajax_Prepaid_GSM_Verification?q="+str,true); xmlhttp.send(); } <...) noBack();" onunload=""> <form action="PrepaidGSMVerification
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...","Ajax_Prepaid_GSM_Verification?q="+str,true); xmlhttp.send(); } <...) noBack();" onunload=""> <form action="PrepaidGSMVerification
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...","Ajax_Prepaid_GSM_Verification?q="+str,true); xmlhttp.send(); } <...) noBack();" onunload=""> <form action="PrepaidGSMVerification
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...","Ajax_Prepaid_GSM_Verification?q="+str,true); xmlhttp.send(); } <...) noBack();" onunload=""> <form action="PrepaidGSMVerification
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...","Ajax_Prepaid_GSM_Verification?q="+str,true); xmlhttp.send(); } <...) noBack();" onunload=""> <form action="PrepaidGSMVerification
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads