I am having a JQuery/ASP issue that I hope someone can help me with.
Scenario: ASP.net application already built and deployed, but in the interest of keeping all clients on the same version (easier to update), I’ve injected a lot of JQuery to customize the ASP application for this client to avoid recompiling the code and having them on a “one off” version.
Here’s what I’m trying to do:
Add validation on a form. Currently I’m grabbing the click event of a “submit” button and doing if statements and checking fields for empty values. IE:
$("input[id*=btnVisualSubmit]").click(function(event) {
if ($("#field").val() == "")
event.preventDefault();
alert("field is empty. ");
});
It’s a bunch of if/else statements that checks each field for empty strings. Now.. what I want to happen is.. if none of those if statements occur, then the normal ASP button to function as is and do all of the code behind. This works fine and dandy so long as the user inputs all of the required fields on the first try. But as soon as I hit the event.preventDefault(), it NEVER submits the form after the user inputs all required fields.
I’ve tried everything from changing event.preventDefault() to “return false” to adding a last “else” statement that just returns a “true” but nothing invokes the submit button unless the user enters all valid data correctly on their first try.
Any help would greatly be appreciated. Thanks
I have used form on submit .see the below code