0

Following is my javascipt function which i want to call when user click on submit kindly let me know how can i make that call????

    <script type='text/javascript'>
    $(document).ready(function(){

  function(e){

                //stop the form from being submitted
                e.preventDefault();
}
    </script>


<input class="bttonn1" type='submit' onClick="" id='send_message' value='Send The Message'>
1
  • 2
    You don't have a form or valid JavaScript. Commented Apr 23, 2012 at 15:11

3 Answers 3

2

Use the submit event on the form element, not click on the submit button.

(And your code is incomplete, you're missing the closing } on the handler function, the closing ); on the call to click [which you'd change], the closing } on the ready handler, and the closing ); on the call to ready.)

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

3 Comments

I MISTAKENLY UPLOADED THE CODE WITH SOME ERRORS KINDLY SEE NOW AND LET ME KNOW HOW CAN I CALL THE FUNCTION??\
issue is being resolved i was getting errors because of not including <!--<script type='text/javascript' src='ajax.googleapis.com/ajax/libs/jquery/1.3.2/…; <script type='text/javascript' src='js/jquery-1.3.2.min.js'></script>
@FaizanQadri: Ah, yes, you do need to be sure to include jQuery before using it. :-) (1.3.2 is very old, though, and be sure you only include it once.)
0

Just like this: http://jsfiddle.net/joeflateau/9c2Fm/

Listen for submit on the form and preventDefault that

1 Comment

issue is being resolved i was getting errors because of not including <!--<script type='text/javascript' src='ajax.googleapis.com/ajax/libs/jquery/1.3.2/…> <script type='text/javascript' src='js/jquery-1.3.2.min.js'></script>
0

If it's just a button then you can just use functions from within the onclick method:

<input class="button1" onClick="sumbitForm()">
<script type="text/javascript">
function submitForm() {
//Your code here
//If you need to get anything from within a form try using document.getElementById(string)
}

Comments

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.