Solved

Making html form fields required

Posted on 2002-03-14
2
253 Views
Last Modified: 2010-08-05
Hi,I have a simple html form that passes 6 variables to a servlet. I would like to make the variables required. I have no preference if I do this in the html or in the servlet. The best solution would use an input box and the minimal solution would just display text telling the user to enter the correct data.

Thanks,
Funim
0
Comment
Question by:funim
2 Comments
 
LVL 9

Accepted Solution

by:
Venci75 earned 100 total points
ID: 6864859
try this in your html page:
<script language="javascript">
<!--
function check_form() {
if (my_form.fld1.value == '') {
  alert('fld1 is empry');
  return false;
}
}
-->
</script>
<Form name="my_form" action="..." method=post onSubmit="return check_form()">
<input type="text" name=fld1>
<input type="submit">
</Form>
<body>
0
 

Author Comment

by:funim
ID: 6864925
Exactly what I was looking for, Thanks -Funim
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 212
java jdbc batch example 8 41
Which non-HTML GUI front end to use with Java? 3 24
Java class and jar 3 22
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question