views:

43

answers:

1

Hello,

var val = $("#desc").val();   // input box
var val2 = $("#type").val();  // select box
if((val=='') || (val2 == ''))
     {
     alert("err");
     }
else { // codes }

when i select dropdown and not type anything on inputbox, the alert err still comes out?

how to make it when dropdown is selected, it goes to else clause?

+3  A: 
var val = $("#desc").val();   // input box
var val2 = $("#type").val();  // select box
if((val=='') && (val2 == ''))
     {
     alert("err");
     }
else { // codes }
Salil
T.J. Crowder
Such a simple fix I almost missed it the first time I read your solution. Well done.
Lucanos
this solution working, my bad.
mckenzie
@T.J. : "*when i select dropdown and not type anything on inputbox, the alert err still comes out?*".That suggests that when he selects a value in the dropdown and leaves the input empty, he does not want the error to show.I think this is a great pick-up by Salil.
Lucanos