Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Team

I want to do this:
function validateValues() {
 
           if ($('#batchIDSelect').val() == '' || $('#batchIDSelect').val() == null) {
               alert("Pls Select the BatchID");
               return false;
           }
return true
}
$("#getCountButton").click(function () {
            debugger;
            if (!validateValues()) {
                return;
            }
         
        });

If the batchid is empty i want to show the message on page ie:"Pls select the batchid "
That i am not getting.Why is it so??.Where i am getting wrong??.
Thanks
Harshal


Kindly Assist
Thanks
Harshal
Posted
Comments
Er. Puneet Goel 4-Apr-14 7:34am    
please post you html block so that we can filter the error.
Peter Leow 4-Apr-14 7:42am    
You code looks find. There could be other causes: how did you call this function? Do you have an element with id="batchIDSelect"? Have you include the jquery library? ...
R Harshal 4-Apr-14 7:59am    
i have the an element with id="batchIDSelect".yes i have include the Jquery Library.

1 solution

Your code seems fine, but you might be getting a value as 0 or something else instead of a blank value. Change the code to monitor that:
1. Event handler is called.
2. What is the value of batch id.

The modified code is:


JavaScript
function validateValues() {
    alert($('#batchIDSelect').val());
    if ($('#batchIDSelect').val() == '' || $('#batchIDSelect').val() == null) {
        alert("Pls Select the BatchID");
        return false;
    }
    return true
}

$("#getCountButton").click(function () {
    alert("click event handler called.");
    debugger;
    if (!validateValues()) {
        return;
    }
});
 
Share this answer
 
Comments
R Harshal 4-Apr-14 9:24am    
My Project was not rebuild properly that why i am facing the issue.Now its working.
Thank you so much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900