RE: Javascript question

by Klaas De Waele <klaas(at)gracegraphics.be>

 Date:  Thu, 13 Dec 2001 09:07:37 +0100
 To:  "'cbirds(at)earthlink.net'" <cbirds(at)earthlink.net>,
"'HWG Techniques'" <hwg-techniques(at)hwg.org>
  todo: View Thread, Original
------------script:

function Validator(theForm)
{
  if (theForm.Budget.value == "")
  {
    alert("Budget moet cijfers bevatten.");
    theForm.Budget.focus();
    return (false);
  }
  if (theForm.Status.value == "" || theForm.Status.value > 100 ||
theForm.Status.value < 0)
  {
    alert("Status moet cijfers bevatten. Schaal van 0 tot 100.");
    theForm.Status.focus();
    return (false);
  }
  if (theForm.Beoordeling.value == "" || theForm.Beoordeling.value > 10 ||
theForm.Beoordeling.value < 0)
  {
    alert("Beoordeling moet cijfers bevatten. Schaal van 0 tot 10.");
    theForm.Beoordeling.focus();
    return (false);
  }
  if (theForm.Startdatum.value == "" || theForm.Startdatum.value ==
theForm.Startdatum.value.replace("/", "test"))
  {
    alert("Startdatum moet een datum zijn (xx/xx/xx).");
    theForm.Startdatum.focus();
    return (false);
  }
  if (theForm.Deadline.value == "" || theForm.Deadline.value ==
theForm.Deadline.value.replace("/", "test"))
  {
    alert("Deadline moet een datum zijn (xx/xx/xx).");
    theForm.Deadline.focus();
    return (false);
  }
  if (theForm.Einddatum.value == "" || theForm.Einddatum.value ==
theForm.Einddatum.value.replace("/", "test"))
  {
    alert("Einddatum moet een datum zijn (xx/xx/xx).");
    theForm.Einddatum.focus();
    return (false);
  }
  if (theForm.Gefactureerd.value == "")
  {
    alert("Gefactureerd moet cijfers bevatten.");
    theForm.Gefactureerd.focus();
    return (false);
  }
  return (true);
}

----------- form:

onsubmit="return Validator(theForm);" name="theForm"


watch out for them linebreaks.  There's some workarounds in here and some
things aren't totally correct (the dates...) - but you can alter the "" to
"whatevercontent" and use it - tested and approved ... ?




> -----Oorspronkelijk bericht-----
> Van: owner-hwg-techniques(at)hwg.org
> [mailto:owner-hwg-techniques(at)hwg.org]Namens cbirds(at)earthlink.net
> Verzonden: woensdag 12 december 2001 22:14
> Aan: HWG Techniques
> Onderwerp: Javascript question
> 
> 
> 
> I am using this code in a javascript to alert people about fields not 
> filled in a form.
> It won't seem to work in the ones that have popups even 
> though I have set 
> the false value to be that of the default selected in the 
> popup menu code.
> 
> How to fix this?
> Here is an example...all the others that work just have the 
> value listed 
> as "" so I thought by entering what WAS selected for those popups, it 
> would give the alert but it doesn't.
> 
> Ones that work on regular fields look like this:
> if (document.name.value == "") {correct = false; 
> alert("Please enter your 
> name!")}
> 
> Ones that do not work that way nor this way on popup menus:
> if (document.state.value == "choosestate") {correct = false; 
> alert("Please select your state!")}
> 
> It also doesn't work if you just have the first bar blank....and code 
> accordingly.
> Any ideas?
> 
> 

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.