473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Required fields?

I'm trying to write a code that will verifiy that each field was fill in. And if not it would return with and error message. Can someone help with this, here is my code so far:

[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<!-- Created with the CoffeeCup HTML Editor 2007 -->
<!-- http://www.coffeecup.com/ -->
<!-- Brewed on 2/18/2008 4:33:53 PM -->
<head>
<title>Customer Information</title>
</head>
<head>
<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false;}
else {return true}
}
}function validate_form(thisform)
{
with (thisform)
{
if (validate_required(email,"Email must be filled out!")==false)
{email.focus();return false;}
}
}
</script>
</head>
<body>
<form action="submitpage.htm" onsubmit="return validate_form(this)"
method="post">

<form method="post" action="button.html">
First name:
<input type="text" name="firstname" size="20">
<br>
Last name:
<input type="text" name="lastname" size="20">
<br>
Email Address:
<input type="text" name="emailaddress" size="70">
<br>
Address:
<input type="text" address="address" size "50">
<br>
City:
<input type="text" city="city" size="20">
<br>
State:
<input type="text" state="state" size="2">
<br>
Zip Code:
<input type="text" zip code="zipcode" size="5">
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>[/HTML]
Feb 22 '08 #1
2 1328
hsriat
1,654 Expert 1GB
What is this line for?

<form method="post" action="button.html">
Feb 22 '08 #2
acoder
16,027 Expert Mod 8TB
ghostrider, please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

Thanks!
Feb 22 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Lorenzo Bolognini | last post by:
Hi all, i need to detect whether a field is required or not. I'm using this code for building a string to convert later to an array (by Split) of which each element matches the field index (ex....
2
by: Cliff R. | last post by:
Hello, I have a form that has a few required fields and also an "agree to terms" checkbox that must be required. I have used Javascripts for both functions individually, but I need a little help...
5
by: Dave Brydon | last post by:
I'm checking for required fields, and using the code below, which I normally have no difficulties with; however, as a twist I decided to return the focus back to the specific field(s) in question...
2
by: bufbec1 | last post by:
I am pretty good with Access, but do not understand VBA. I have researched this topic and see only VBA answers, so I hope someone can help with my specific question. I have 2 fields for an...
3
by: Orchid | last post by:
Hello All, Hope someone can help me on my required field problems. I have a form base on a table for users to input new Employees. There are 4 fields that cannot be Null when entering new...
3
by: kaosyeti | last post by:
i have a form that has required fields and i have a delete button, created by the wizard, that has this code for onclick: Private Sub cmddeleterecord_Click() On Error GoTo...
7
by: Tom van Stiphout | last post by:
I want to indicate requiredness by setting the background color of the control. Ideally I would call a sub in Form_Load to just do its thing. Below is what I have so far, but I realize this is of...
10
by: jasone | last post by:
hi everyone! any advice given will be MUCH appreciated, i have spent about 10 hours on this bit of script... a rating system. I am having realt trouble overcoming this problem at runtime ...
1
by: KMEscherich | last post by:
Hi there, am wondering if there is a way to have this code capture 2 dates. You see, I have several fields and some are REQUIRED fields and some are NON-REQUIRED fields. I am attempting to capture...
7
by: samdev | last post by:
I have set up a table with a few fields that are set to required....all work fine except the fields that are Lookup from another table. What am I forgetting to set? Thanks!!
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.