473,800 Members | 2,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form Validation with alert box

Hi

Would someone have a basic example of form validation that validates
name and address, but using only one alert box that displays which
fields haven't been completed? I can do it on an individual basis, but
want to consolidate it to one alert message.

G

Aug 27 '06 #1
4 3291

"Gregc." <gr*********@bi gpond.comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
Hi

Would someone have a basic example of form validation that validates
name and address, but using only one alert box that displays which
fields haven't been completed? I can do it on an individual basis, but
want to consolidate it to one alert message.

G
Why not show what you have so far?

Tim
Aug 27 '06 #2
Gregc. wrote:
Hi

Would someone have a basic example of form validation that validates
name and address, but using only one alert box that displays which
fields haven't been completed? I can do it on an individual basis, but
want to consolidate it to one alert message.
Loop through the controls and check them. Start with an empty error
message string, then concatenate error messages as you go. When you've
finished, check the string. If it's empty, you haven't detected any
errors. Otherwise, display the message.

A better solution is to have an error message area associated with each
input that is validated. Validate individual controls onblur (or onkey
press, onchange, whatever suits) and write error messages to the error
message area. That way the user can see the messages and correct the
input while it's still there. When they get it right, the message
disappears.

It fits well with server-side validation too - the validated page is
returned with server-supplied messages in the error message areas.

There are lots of examples in the archives.
--
Rob

Aug 28 '06 #3

Tim Williams wrote:
>Why not show what you have so far?

Tim
Tim, this is what I have done so far:

<html>
<head>
<script type="text/javascript">
function updateOrder(obj ){
var type = obj.name;
var pizza= new Array("Supreme" , 12);
var pizza2 = new Array("Italian" ,12);
var w=obj.selectedI ndex;
var selected_text = obj.options[w].text;
var qty1=document.g etElementById(" orderQty");
var piz1=document.g etElementById(" PizzaType")
var oSum = document.forms. form1.orderQty;
var inLisAlready = false;

for(i=0; i<oSum.length; i++){
if(oSum.options[i].value==qty){
if(obj.value==0 ){
oSum.options[i]=null;
}
else
{oSum.options[i].text=(obj.valu e);
}
inLisAlready=tr ue;
break;
}
}
if (!inLisAlready) {
if(obj.value!=0 ){
oSum.options[oSum.length]= new Option (obj.value);
}

}

}

</script>
</head>
</script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0 "
style="text-align:center">
<form name="form1" method="post" action="" onsubmit="">
<select name="Supreme" id="Supreme" onchange="updat eOrder(this);">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0 "
style="text-align:center">
<form name="form1" method="post" action="" onsubmit="">
<select name="Italian" id="Italian" onchange="updat eOrder(this);">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<td bgcolor="#FFE9B B" class="borderBR "><select name="Type of Pizza"
size="10" id="PizzaType" >

<option>Pizza Ordered</option>

</select </td>
<td bgcolor="#FFE9B B" class="borderBR "><select name="orderQty" size="4"
multiple="multi ple" id="orderQty">
</select>

</body>
</html>

Aug 28 '06 #4

Gregc. wrote:
I ended up working it out.

Greg

Aug 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2372
by: Andrew Williams | last post by:
Does anyone know of a way to quickly validate an HTML web form? I need to make sure that certain fields on my form actually contain data and are not submitted blank. I have tried using client-side Javascript validation which flags up when a field is empty but the form is still submitted. Here is the ASP code I am using to submit the form to an e- mail with CDONTS:
6
4345
by: Charles Banas | last post by:
weird subject - i hope more than just one curious regular will hear me out. :) ok, i've got a bit of a big problem, and i need answers as soon as possible. i know this forum is meant for web developers, but is relevant discussion. i'm not OT here unless someone thinks i'm trolling (which i'm not, obviously). then i'll disappear and never show my face again. :P
7
4894
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes because then it didn't work in IE. How can I enable this javascipt form validation to work in Netscape? When I use netscape, none of the alert boxes appear. It submits the form without validating anything.
4
1832
by: Semi Head | last post by:
Hello folks, I'm looking for a script to validate a specific number value in a standard form input field. An example would be, if someone enters a number into a form input, I want the script to validate it and give an alert if that the number exceeds the set script value. Like if the script value is set for 3000 and the number 3002 is entered, I want an alert to pop and give a warning, BTW - This script must be generic enough to work...
11
2537
by: greg.scharlemann | last post by:
I've been playing with this form validation method for a while and have tried an array of things but haven't had any luck with a couple items. 1. The validateForm() function doesn't detect when the Min price is greater than the maximum price. 2. The validateForm() function doesn't call isNumber() on the minBaths, maxBaths, minBeds, or maxBeds. 3. Despite errors in input and the validateForm() function returning false, the form is still...
9
4181
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be honest I usually hire someone to do it for me, grab predone scripts and kind of hack out the parts that I need, or just do very minimal validation (e.g. this is numeric, this is alpha-numeric, etc.)
2
4896
by: this one | last post by:
I have the following code <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" src="..\include\gen_validatorv2.js" type="text/javascript"></script> </head>
5
1933
by: kevinmajor1 | last post by:
Hello, all. I'm currently trying to write a script that will perform form validation upon submission. I know that more validation should be performed on the server's side...this is just a test to see if I can get the client side to work. My problem is that I'm trying to make a validator that is 100% separated from the XHTML code. I don't even want an event handler assignment in the form. Unfortunately, I can't see how to grab a hold...
8
6704
by: M.L. | last post by:
Hello. I created a form using JS validation with the form tag as follows: <form name="form1" action="dynaform.php" method="post" onsubmit="return pvg_sub();"> The js validation script sends alerts when fields are not entered properly and it seems to work, except...when there are no errors, instead executing the php action script, I get a popup dialog box in IE6 asking if I want to download or run the php script. Can anyone tell me
3
3301
uranuskid
by: uranuskid | last post by:
Hey folks, I was going to include a contact form on my website. Well, in the first place that seemed an easy thing to do with a form that prompts a PHP file validating the input vaiables and using it's mail () function to send the mail. However, as I got more into that topic I realized that one should be really concerned about the validation part to prevent spam abuse. There are shiploads of 'mail scripts' available with each of them has...
0
9694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10509
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10039
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7584
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6824
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4152
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2953
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.