0

I have been making a javascript form validator to provide live form validation. If there is an error it should stop the submission but it doesn't. I have tried returning false and using preventDefault() but it still doesn't prevent submission. I have tried to find the answer else where but I can't, so can any of you help me out.

The form is on http://swanleyhypnotherapist.co.uk/contact.html.

Thanks in advance.

1
  • 2
    Could you paste the relevant code into this post, please? Commented Jan 22, 2013 at 17:22

1 Answer 1

2

Simple mistake.

Replace:

<form name="contact" action="/" onsubmit="check();">

With:

<form name="contact" action="/" onsubmit="return check();">
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks. I changed it but it still doesn't work. What else have I done wrong.
Okay, have you updated it in the website? Can I check it live?
@user2001154 Give return false; before event.preventDefault(); or remove event.preventDefault(); for now and check. Also, remove the evt parameter.
Sorry. I was busy so I have only just checked it. It does appear to work. I didn't at first add preventDefault() but I tried it when it wasn't working. The problem must have been leaving out return in the onsubmit attribute and when I corrected it the preventDefault I had added was the problem. Thanks for your help guys.

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.