0

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?

1
  • 1
    You need to show us how you're capturing the event... Commented May 13, 2010 at 6:13

1 Answer 1

3
var val = $("#desc").val();   // input box
var val2 = $("#type").val();  // select box
if((val=='') && (val2 == ''))
     {
     alert("err");
     }
else { // codes }
Sign up to request clarification or add additional context in comments.

3 Comments

Huh? How do you know he wants && instead of ||? I'm not seeing that implied in the question anywhere.
Such a simple fix I almost missed it the first time I read your solution. Well done.
@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.