RE: more onsubmit questions
by Klaas De Waele <klaas(at)gracegraphics.be>
|
| Date: |
Wed, 4 Jul 2001 10:08:46 +0200 |
| To: |
"'Nate Harel'" <nharel(at)consultant.com>, "'hwg-techniques(at)hwg.org'" <hwg-techniques(at)hwg.org> |
| |
todo: View
Thread,
Original
|
|
<script language="javascript">
function check() {
if (theform.Naam.value == "") {
alert('Geef een naam in');
theform.Naam.focus();
return (false)
}
if (theform.Beschrijving.value == "") {
alert('Geef een beschrijving in');
theform.Beschrijving.focus();
return (false)
}
if (theform.Prijs.value == "") {
alert('Geef een prijs in');
theform.Prijs.focus();
return (false)
}
return (true);
}
</script>
it'll run through all validators first, do a return false as soon as one
fails, otherwise return true.
Basic FrontPage routine...
- Kayjey -
-----Oorspronkelijk bericht-----
Van: owner-hwg-techniques(at)hwg.org
[mailto:owner-hwg-techniques(at)hwg.org]Namens Nate Harel
Verzonden: dinsdag 3 juli 2001 23:35
Aan: hwg-techniques(at)hwg.org
Onderwerp: more onsubmit questions
Hi all,
I have a form that validates an entry before being submitted as follows:
===================================================
<FORM
method="post"
name="buyit"
onsubmit="return validate(buyit.eop_Size , '<H2>Please select a size
for
ordering....</H2>')" action="/cgi-bin/cartit.cgi" target="_blank">
=======================================================
Essentially, it is looking if there is any value in the field or if it is
blank. If blank it does not submit but returns a warning note. The
validation code is below:
=========================================
function validate(field, comment)
{
var formset = field;
if ( formset.value != "" )
{
window.close();
return true;
}
else
{
document.write(comment);
window.setTimeout('history.back()', '1500');
return false;
}
============================================
So far, so good. All works well.
HOWEVER, I need to verify more than 1 field at times, perhaps 3-4 fields.
Is there a way to do this with the JS code, or simply add another test to
the FORM or what ???
Thanks for your help.
Nate
---------------------------------------------------
Nate Harel
NetTech Services
66 Carol Road
Needham, MA 02492-1108
Tel: 1-781-559-8176
Toll Free: 1-877-567-8936
FAX: 1-877-567-8936
Email: nharel(at)consultant.com
www.nettsv.com
----------------------------------------------------
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA
This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.