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



Home Answers Viewqa JSP-Servlet How to validate a form

Have Programming Question? Ask it here!
 
 
 


harini
How to validate a form
1 Answer(s)      4 years and a month 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
validate select option jquery
validate select option jquery  How to Validate select option in JQuery
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
how to featch data form db?
how to featch data form db?  how to featch data form db?   ...; </a> <div class="search" <form class="form-search"> <div class="input-append">
how to create a user registration form in php
how to create a user registration form in php  how to create a user registration form in php
how to use a image in background in your application form?
how to use a image in background in your application form?  how to use a image in background in your application form
How To Write the FORM Tag Correctly for Uploading Files?
How To Write the FORM Tag Correctly for Uploading Files?  How To Write the FORM Tag Correctly for Uploading Files
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
how to post data in mysql php form
how to post data in mysql php form  how to post data in mysql php form
How can you handle form in Spring 3.2 MVC?
How can you handle form in Spring 3.2 MVC?  Hi, How can you handle... the Spring 3.2 MVC Form Handling to accept inputs and validate the correct data... the How can you handle form in Spring 3.2 MVC?   Hi, This article
validate bank account number
validate bank account number  how to validate bank account number in jsp
validate bank account number
validate bank account number  how to validate bank account number in jsp
validate parameter before using it
validate parameter before using it   How to validate the parameter before using it in JSP
Validate telnet connectivity
Validate telnet connectivity  How to validate telnet connectivity in my java code
validate() method of ActionForm work
validate() method of ActionForm work  How does validate() method of ActionForm work
reset() and Validate() method
reset() and Validate() method   How does reset() and Validate() method struts work
How to Validate JRadioButton and How to Save data from JRadioButton to MS Access Database - Java Beginners
How to Validate JRadioButton and How to Save data from JRadioButton to MS Access Database  Hello Sir I want Store Corse Type that contains Two JRadioButton I want Store Information from JRadioButton to MS Access Database, and I
how to login form through spring dao module
how to login form through spring dao module  here i want to chek user details in database through form by using spring dao module.please give me some reference example to me
how to work with dynaaction form in lomboz - Struts
how to work with dynaaction form in lomboz  hi friends i have on doubt regarding about how to use and work with struts dynaaction form in lomboz i know how to work with actionform in struts plzzzzzzzzzzzzzzzzzz send reply
How do I compile the registration form?
How do I compile the registration form?  How do I compile the registration form as stated at the bottom of the following page (URL is below). Do I need ANT? If so, please give instructions. I am a student. http
Advertisements
 

 

 

DMCA.com