Jump to content

[SOLVED] How to validate a checkbox and text field together


damerit

Recommended Posts

I want to validate so that if the checkbox of 'bypass' is not checked or if a text field = "" then a message to choose one or the other. I wrote the one below but it deeps asking for input both. I even used the or || operator.

 

Can someone help me make sense of this? .... thnks

 

function validateForm(thisForm){ 
   if ((thisForm.bypass.checked == true) && (thisForm.whatObject.value == "")){
  	alert("Enter an answer or check bypass.");
return false;
  }
  

 

I added a true statement and it worked.

 

function validateForm(thisForm){

  if ((thisForm.severity.value == "High") && (thisForm.bypass.checked == true)

                                                      && (thisForm.whatObject.value == "")){

  alert("Enter an answer or check bypass.");

return false;

  }

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.