[thelist] js testing for empty fields

Abdullah Shaikh abdullah at uxdg.com
Thu Feb 13 11:23:05 CST 2003


you could also just check for:

    if(myForm.elements['myField'].value) { doSomething() }

assuming your form was anything but boolean



----- Original Message -----
From: "Tom Dell'Aringa" <pixelmech at yahoo.com>
To: <thelist at lists.evolt.org>
Sent: Thursday, February 13, 2003 6:12 AM
Subject: [thelist] js testing for empty fields


> Hey all,
>
> Normally I've always checked for empty fields in my forms by doing:
>
> if(myForm.elements['myField'].value == "")
>   //field is empty
>
> But I have also seen this:
>
> if
>
((myForm.elements['myField'].value==null)||(myForm.elements['myField'].value
==""))
>   //field is empty
>
> Is it really necessary to check for the null value? How would a field
> have a null value but not a "" value?
>
> Tom
>
>
>
> =====
> var me = tom.pixelmech.webDeveloper();
>
> http://www.pixelmech.com/
> http://www.maccaws.com/
> [Making A Commercial Case for Adopting Web Standards]
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Shopping - Send Flowers for Valentine's Day
> http://shopping.yahoo.com
>





More information about the thelist mailing list