Stop form submit with onClick?

Tags: , , , ,
Posted in dotnet, vb, vb.net | No Comments »

I’m using an image as my submit button. I want it to check to ensure all boxes have a value before submitting (I will make the verification more stringent later), and if there is none, to cancel the form submission. I created a readonly input box that changes from white to a visible color to use as a status indicator for now. It displays the correct status in either scenario, but return false doesn’t seem to be stopping the page from loading. What function would do that? Thanks. :)

<form method="post" action="send.php">

...

...

<input type=image src="submitbutton.jpg" 

alt="Click Here To Submit" onClick="javascript:sendform();"></form>

Earlier in the page I created the function below…

function sendform(){
//verification script.
        if ((document.forms[0].variable1.value=="") || (document.forms[0].variable2.value=="") || (document.forms[0].variable3.value==""))
        {
        //Update the sending status.
        document.forms[0].statusindicator.value='Please fill in all forms.';
        alert("Please fill in all forms. Thanks.");
        return false;
        } else {
        //Update the sending status.
        document.forms[0].statusindicator.value='Sending...Please Wait.';
        }
}

Similar:

  1. jQuery.Form wont submit Im?trying to submit a form without refreshing the page, but I?m having a problem. When I click submit the page refreshes and anothing gets posted....
  2. jQuery submit handler for form with single input field doesn’t trigger on IE I have a form with an input element but no submit button. I use jQuery to attach an onsubmit handler: $('#tickerbox-form').submit(function (ev) { alert('submit'); //...
  3. overriding form submit event with jquery Hi, I cannot find a solution for that, I need to override a previous setted submit event handler. In my example, I have a iframe...
  4. Use text links to submit a form Hi this is a jquery question. I want to use a text link to submit a form and get the POST values instead of an...
  5. using jquery to create a new form I have a stepped form that has validations on each step. So to submit the full form I created 2 methods to search through each...

Tags: , , , ,

Leave a Reply