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



Home Answers Viewqa JSP-Servlet How to validate a form
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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

Advertisement
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 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 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 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 design a form using java?
How to design a form using java?  Please help in designing of form using java for my project
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...=xmlhttp.responseText; } } xmlhttp.open("GET","Ajax_Prepaid_GSM_Verification?q="+str
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 convert a swing form to PDF
How to convert a swing form to PDF  Sir, I want to know about how convert a swing form containing textbox,JTable,JPanel,JLabel, Seperator etc swing menus to a PDF file using java code
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
How to Open a File in HTML Form
How to Open a File in HTML Form  Hi, My question in that how could i open a file in HTML Form. Could any one suggest me the examples or online help... it. Otherwise take this examples and syntax that will show how to Open a file in HTML
 

 

 

DMCA.com