Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Making html form fields required

Posted on 2002-03-14
2
Medium Priority
?
258 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 400 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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

783 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