Home Answers Viewqa JSP-Servlet How to validate a form

 
 


harini
How to validate a form
1 Answer(s)      2 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.
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









Related Pages:
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
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
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 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 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 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
javascript regex validate currency
javascript regex validate currency  How to validate currency...="validate();" /> </body> </html> In general currency is in form... validate() { var currency = document.getElementById("currency").value
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 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 } <
long validate
long validate  How to validate long type
Validate TextArea
Validate TextArea       In this section, you will learn how to validate your text area...; <s:form action="characterLimit1" method="POST" validate="true
JavaScript validate select tag
JavaScript validate select tag In this tutorial, you will learn how to validate html select tag. Here, we have used two select tags to select numbers...; <script language = "Javascript"> function validate
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
JavaScript regex validate validate Zip.
JavaScript regex validate validate Zip.  JavaScript regex validate - how to validate Zip?   <html> <head> <title>Zip Code...; function validate() { var zip = document.getElementById("zip").value
validate select option jquery
validate select option jquery  How to Validate select option in JQuery
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>
Registration Form
username,password,date of birth,Mobile number number into database. How to insert Date of birth from Drop down to database and how to validate user entered String
Validate telnet connectivity
Validate telnet connectivity  How to validate telnet connectivity in my java code
validate bank account number
validate bank account number  how to validate bank account number in jsp
reset() and Validate() method
reset() and Validate() method   How does reset() and Validate() method struts work
validate() method of ActionForm work
validate() method of ActionForm work  How does validate() method of ActionForm work
validate parameter before using it
validate parameter before using it   How to validate the parameter before using it in JSP
validate bank account number
validate bank account number  how to validate bank account number in jsp
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations  <%@page import="java.sql.SQLException"%> <%@page import="com.rajsoft.CAF.util.DBconnection"%> <%@page import="java.sql.Statement"%> <
validate text field iPhone
validate text field iPhone  i got two different UITextfield in my iPhone application for user login. Just wondering how to validate
Validate <select> tag Items
Validate select tag Items  Hi, How to validate addition of two numbers of two different "select" tag items in JavaScript..? Thanks in advance
Validate <select> tag Items
Validate select tag Items  Hi, How to validate addition of two numbers of two different "select" tag items in JavaScript..? Thanks in advance
Ajax form validation Example
Ajax form validation Example  Hi, I want to validate my ajax form... jQuery to validate Email Address tutorial. In this tutorial you will learn how to validate form in Ajax using jQuery framework. Thanks
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...) noBack();" onunload=""> <form action="PrepaidGSMVerification...:20px;">PAN/Form 60/61 Signed by Customer</td>
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...) noBack();" onunload=""> <form action="PrepaidGSMVerification...:20px;">PAN/Form 60/61 Signed by Customer</td>
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...) noBack();" onunload=""> <form action="PrepaidGSMVerification...:20px;">PAN/Form 60/61 Signed by Customer</td>
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...) noBack();" onunload=""> <form action="PrepaidGSMVerification...:20px;">PAN/Form 60/61 Signed by Customer</td>
how to validate javascriptcode n i am attaching file give validations
how to validate javascriptcode n i am attaching file give validations ...) noBack();" onunload=""> <form action="PrepaidGSMVerification...:20px;">PAN/Form 60/61 Signed by Customer</td>
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
validate input php
validate input php  How to validate the input fields in PHP & HTML.   Hi, Please let's know many fields is to be validated. Then I will make an example for you. Thanks
spring form validation
spring form validation  how can we validate a web form using spring, try to give an example of the form containing some fields and their validations,ASAP......   Please visit the following link: Spring form validation
HTML form examples
HTML form examples  Hi, How to create a simple data entry form in HTML and use JavaScript to validate the same. Can anyone share html form examples code? Thanks   Hi, Please see the HTML form example page. Thanks
javascript regex validate url
javascript regex validate url  How to validate URL in regex... regex</title> <script type="text/javascript"> function validate...; <input type="submit" value="Check" onclick="validate();" /> </body>
validation using validate method
validation using validate method  HOW TO DO THE VALIDATION IN THE STRUTS 2 USING VALIDATE METHOD IN ACTION CLASS,AND ALSO AM HAVING MY BEAN CLASS AS SEPERATE. I HAD TRIED THAT BUT IT WAS NOT WORKING PROPERLY. IF U KNOW
preg_match validate
preg_match validate  what is preg_match and how can i use it to validate the input field.   Hi, in preg_match you can define any pattern... can validate the input ?> Thanks
validate email objective c
validate email objective c  how can i validate email text field in objective c? is there any method that support multiple email address separated by coma.   - (BOOL)validateEmailWithString:(NSString*)email
JavaScript Validate UK Date
JavaScript Validate UK Date  How to Validate UK Date in JavaScript   <SCRIPT> function validateDate(dtControl) { var input = document.getElementById(dtControl) var validformat=/^\d{1,2}\/\d
HTML Form Validation example
HTML Form Validation example  Can anyone guide me how to validate the user name and password field in HTML using simple or JavaScript Validation. Thanks in advance!   <form method="post" onsubmit="return
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
Validate ID Number
Validate ID Number   How to validate South African ID Number using java.. I can do it using c# but, when it comes to java i;m clueless please help me   Here is a code that check whether the south African Id is valid
login form validation - JSP-Servlet
login form validation  hi, how to validate the login form that contains user name and password using post method . the validation should not allow user to login in the address bar thanks regards, anand

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.