Solved

Making html form fields required

Posted on 2002-03-14
2
247 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now