0

im trying to make it so when someone hits submit and a feild is empty or blank i message pops up and says "must fill in required feilds" near the bottom of the form rather than having a new page open up and say it.

3
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by WhiteLeo
0

I would suggest using Javascript to validate the form, and then once the form has been sent validate it again using php.

Javascript validation is easy, just google for "Javascript Form Validation" and pleanty of examples appear.

The reason you must validate again using Php is because user's can disable javascript, so you shouldn't rely on users browsers to validate the form. It makes it easier for users, but it shouldn't replace your normal validation.

http://www.w3schools.com/js/js_form_validation.asp
That's the example I learned off.

0

The problem with using JavaScript is that the user can disable Javascript.

You could try using the strlen function.

0

The problem with using JavaScript is that the user can disable Javascript.

You could try using the strlen function.

Which is why I said the form should be validated a second time using php.

He wants the user to be informed on the same page without the page reloading, and you do that with javascript.

If the user hasn't got it enabled, then the php still validates the form.

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.