How to validate a form

How to validate a form

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 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
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
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
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
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
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
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
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 design a form using java?
How to design a form using java?  Please help in designing of form using java for my project
long validate
long validate  How to validate long type
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 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
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>
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
How to create simple HTML Form?
HTML Form Tutorial: How to create simple HTML Form? In web application input forms are developed using the HTML tags and the form component provided...? How to Create Student Registration Form with HTML Code
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
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 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
Login form in Struts2 version 2.3.16
How to create Login Form in Struts2? In this video tutorial I am explaining you about the source code of the program to create the Login form in Struts2... at roseindia.net how to make a login form in Struts2. Check more Struts 2
validate select option jquery
validate select option jquery  How to Validate select option in JQuery
How to make login form in Struts 2?
How to make login form in Struts 2?  Hi, How to make login form in Struts 2? Thanks   Hi, If you want to learn to make Login form in Struts then check following tutorial: How to create Login Form in Struts2? Thanks
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">
form
form   Can I prevent a form from being submitted again
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 post data in mysql php form
how to post data in mysql php form  how to post data in mysql php form
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
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 can i display a editable result of form?
how can i display a editable result of form?  how can i display a editable result of form? i know how to display form result but the result is display on text. i cant modify them. i have a form with hundreds of checkbox. i want
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
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 save a gui form in core java
how to save a gui form in core java  please help me i am java beginner how to save a jframe containing jtable and panels in java thank you
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 bank account number
validate bank account number  how to validate bank account number in jsp
Validate telnet connectivity
Validate telnet connectivity  How to validate telnet connectivity in my java code

Ads