0

I have JavaScript code including several functions, the main one being CheckForm().

The function is called by clicking the 'Submit' button:

<td><input type="submit" name="submit1" id="submit1" value="Register" onclick="return CheckForm();"/></td>    

But when the button is pressed nothing happens (the function isn't performed). What can I do to fix this?

4
  • 7
    Post the code for the function Commented Apr 2, 2013 at 10:44
  • 2
    put a console.log / or alert in the top of the function so you know if it gets fired at all Commented Apr 2, 2013 at 10:47
  • 1
    Anything in the error console in firebug? Commented Apr 2, 2013 at 10:47
  • Can you write the skeleton of checkForm code? Can you check the browser log to see if there is any error in the page? Commented Apr 2, 2013 at 10:48

2 Answers 2

2

Have you tried debugging your code using FireBug or jsFiddle?

Some possible causes are an incorrectly named function or function call(remember that JavaScript is case sensitive), an error in your function or your JavaScript code not being referenced in your page.

If you aren't using either of the above tools then try using a console.log or alert inside your function to see if it is being called.

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

1 Comment

thanks a lot Alan, you've solved my problem. I forgot JS is case sensitive and accidentally had an Uppercase letter instead of it being Lowercase. Thanks again!
0

You can use it like this.

function CheckForm()
{
 //doing stuff
  return true;
}

<form id="formToCheck"></form>


$('#formToCheck').submit(CheckForm);

Hope it helps

if you want to do it without jquery just add on

   <form onSubmit="return CheckForm()"></form>

You can read more about form validation without jQuery here -> http://www.w3schools.com/js/js_form_validation.asp#gsc.tab=0

Maybe if it doesn't work you have some errors. Check JS console in your browser and remove them.

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.