I have multple objects. Before submitting a form, I want to check to be sure all of the object values are “ok”.
$("#sub_button").click(function() {
if (myObj.login_id && myObj.email == "ok") {
alert("This would submit the form. login ID obj is: "+myObj.login_id+" and email email obj is: "+myObj.email);
} else {
alert("the form is bad!");
}
});
I’ve tried it with two == and three ===, it still isn’t working. The myObj.login_id or myObj.email could equal ANYTHING and it still pops up the “This would submit the form” alert, and shows in the alert box that the value(s) is NOT “ok”.
What am I doing wrong?
You should do:
In your code you just check that
myObj.login_idresolves to true (which happens everytimemyObj.login_idvalue is not in this list)