i have site contact form that validates required fields w/ .js And php.
if browser has javascript turned on, the req'd info error message will show next to the field boxes ..

if javascript is turned off, then
user will see the same thing but coming from php instead...

the submit goes to database and personal email.
email received shows complete field boxes info.. as expected..

the database will show incomplete submissions that the .js was sposed to stop..
example:: like name is filled but missing email and such..

how can this be so?...
must be something simple//

i didnt try to disable the .js validation to see what happens..
i would rather fix it and keep it

here is code if someone can look at it..


5 Years
Discussion Span
Last Post by paulkd


I'm not a JavaScript guru, and I use jQuery because it make client side stuff so easy and logical. That having said, this line (and others) does not appear correct:-

// Get the form
var form = $('comments_form');

What is $('comments_form'); ?

is there another js file that you have not mentioned?

Edited by paulkd: missed a bit more


this is the behaviour :

form submission possibilities:
fill in name only == js blocks

fill in valid email only == js blocks

fill in bad email format == js doesnt block

fill in name + email wrong format == js blocks

fill in name + email correct format == js blocks

Edited by amkaos


I admit I haven't tried your linked code, because var form = $('comments_form'); does not seem valid to me, which may be the reason you are having this issue.

Quick note: You should always validate server side, even if you have used JavaScript to validate user input.


php does validate.but i spose it doesnt work for database either.. should i replace 'comments_form' with contact.php?

Edited by amkaos


i am using mootools.. i just dont know how to fix the script


You haven't set values for nameError, emailError and commentError in your form.addEvent function.

This error is preventing your e.stop() from stopping your form being submitted.


You still haven't addressed the js omissions I highlighted. However, add this to the top of your PHP form handler for testing.

var_dump($_POST); die;

i am using mootools.. i just dont know how to fix the script

So it's not your script?


sorry, i did try what you said for the js, but no change..i forgot to type it..i will do your second sugg. tyvm


using your sugg, this is output when i reloaded the form:

array(6) { ["fullname"]=> string(0) "" ["email"]=> string(0) "" ["comment"]=> string(0) "" ["honeypot"]=> string(0) "" ["user"]=> string(0) "" ["submit"]=> string(12) "Send Message" }

They are all empty. So, presumably the javascript didn't kick in to prevent form submission?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.