Noongar Posted March 15, 2012 Share Posted March 15, 2012 Does anyone know why I am not getting an alert on an empty form INPUT value? if (document.forms["form"]["targetname"].value == "" && document.forms["form"]["unknownname"] == false) { alert ("What ever"); return false; } document.forms["form"]["targetname"] is a form INPUT text document.forms["form"]["unknownname"] is a form INPUT checkbox I suspect the problem is due to 'false'.. but I can't figure out why. Quote Link to comment https://forums.phpfreaks.com/topic/259027-am-i-using-false-the-correct-way/ Share on other sites More sharing options...
requinix Posted March 15, 2012 Share Posted March 15, 2012 Look at .checked. And unless you like using ==false you can just use a not (!): !document.forms["form"]["unknownname"].checked Quote Link to comment https://forums.phpfreaks.com/topic/259027-am-i-using-false-the-correct-way/#findComment-1327918 Share on other sites More sharing options...
Noongar Posted March 15, 2012 Author Share Posted March 15, 2012 Ahhhh I see! Thanks for teaching me that man. I have never used check boxes ever before, so yeah. Well, thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/259027-am-i-using-false-the-correct-way/#findComment-1327919 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.