Distortion Posted April 14, 2010 Share Posted April 14, 2010 if (document.getElementById("name")) {}Just for confirmation, this checks wether the element exists and if it's value is higher than 0. Am I right? Link to comment Share on other sites More sharing options...
jeffman Posted April 14, 2010 Share Posted April 14, 2010 It will test for existence, but says nothing about value. Most element types don't even have a value property. If you want to check that, you'll need to explicitly access it, as in document.getElementById("name").valueBe sure you do that after you test for existence (assuming existence really is in question). Link to comment Share on other sites More sharing options...
Distortion Posted April 14, 2010 Author Share Posted April 14, 2010 Thank you, that was what I needed to hear.I'd hoped that one could check existance and value at once but as it turns out, I had to use 2 separated conditions. At least I found out why my script wasn't working. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.