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.

Recommended Answers

All 3 Replies

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.

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

You could try using the strlen function.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.