0

I have a imagebutton as following :

<asp:ImageButton ID="Send" runat="server" ImageUrl="~/images/send.gif" OnClientClick="javascript:return checkDataAndConfirmSendToVOA();" AlternateText="Send" />

when this button is clicked using my jquery i am looking for a hidden value if it is null I replace the image as follow:

 $("input[id$='Send']").click(function(e) {
                        if($("input[id$=imageThumb]").val() == 0)
                          {
                                var errorImage = "../Images/add.png";
                                $('#drop').append('<div class="p" id="'+Id[1]+'_c"><div class="Image"><input name="thumbImage" type="hidden" id="thumbImage" value="' + Title +'" /><img src="'+errorImage+'" title="'+Title+'"/></div><div class="Info"><span class="name"> Name : '+Title+'</span> </div></div><div class="clear"></div>')

                          }

now how would I make sure the page doesn't submit if there is error? i.e. the user stay in same page and just show an error

1 Answer 1

2

Just return false from within the if statement as so:

 $("input[id$='Send']").click(function(e) {
    if($("input[id$=imageThumb]").val() == 0){
        var errorImage = "../Images/add.png";
        $('#drop').append('<div class="p" id="'+Id[1]+'_c"><div class="Image"><input name="thumbImage" type="hidden" id="thumbImage" value="' + Title +'" /><img src="'+errorImage+'" title="'+Title+'"/></div><div class="Info"><span class="name"> Name : '+Title+'</span> </div></div><div class="clear"></div>');

       return false;

    }
 }
Sign up to request clarification or add additional context in comments.

1 Comment

I am returning false but still the form goes through...btw i have some javascript validation in the button as well as shown above

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.