Click to See Complete Forum and Search --> : java error on simple validate script


webworks
04-08-2003, 03:53 PM
Hi folks :)

These payment forms link to a shopping cart script which doesn't have the option to require the fields. I'm trying to use javascript to require the quantity field, but I'm getting a "value is null or not an object " error. Can any java gurus help me out?

Thanks in advance for your response, and here's the link:
http://www.covingtonplace.com/thankyou_apply_hdm2.htm

Thanks!
Heather Mc

Jona
04-08-2003, 04:08 PM
The site works for me, and I use IE 6.

webworks
04-08-2003, 04:18 PM
The alert does work, if you remove the default 1. But, if you just go to the link: http://www.covingtonplace.com/thankyou_apply_hdm2.htm

and select "payonline" it gives the error. (on 6.0).

Try it... payonline doesn't bring you anywhere but to your totals -

Jona
04-08-2003, 04:22 PM
I only get an error when I put "0" in the box. When nothing is in it, it works fine; does not submit the form, alerts me, and sets the focus to the form element. I don't know why 0 returns an error, because null operates in the like manner of "0." But you can try this just in case:

function isEmpty(aTextField) {
if(document.forms[0][aTextField].value.length==0 || (document.forms[0][aTextField].value==null || document.forms[0][aTextField].value=="0"){return true;}else{return false; } }

I kinda' changed up the code, but it should work just fine.

webworks
04-08-2003, 04:58 PM
Thanks so much for the help...can you tell I'm not very good at this? ...something wrong somewhere :(

Jona
04-08-2003, 05:01 PM
The code I posted works, but let me see if I can pick up the error...

Jona
04-08-2003, 05:04 PM
Okay, here is what you have:

function isEmpty(aTextField) {
if(document.forms[0][aTextField].value.length==0 || (document.forms[0][aTextField].value==null || document.forms[0][aTextField].value=="0"){
return true;
}
else { return false; }
}

It should be:

function isEmpty(aTextField) {
if(document.forms[0][aTextField].value.length==0 || document.forms[0][aTextField].value==null || document.forms[0][aTextField].value=="0"){
return true;
}
else { return false; }
}

Okay? That's the first error...

Jona
04-08-2003, 05:07 PM
The next and last error I get is an "Object Expected" error, on line 423. I would help you, but I'm not going to count 423 lines of code just to see where the error is. It works fine, even though it returns an error (which I don't know why).