Form Acceptance

I have a form, a couple of the fields NEED to be filled with something.

I used REQUIRED on the form, and pressed the submit button to go to the next page, and it let me. Bypassing any "required" fields.

I need to be able to disable the "SUBMIT" button I think, until my requirements are met for the other 2 fields. I need these 2 fields not to be blank because one is a Unique index, and one is a main picture that is an ANCHOR for another page.

Then again is this even the right thought process?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Please post the form, using the code snippet, thanks.

You may want to use jQuery for a good client-side experience.  Whether or not you choose that, you must validate the input on the server-side.
>>Then again is this even the right thought process?
No.  You are relying on client-side validation.  I can create a perl script and emit a "submit" of your form without your required fields.

Thus, what you really need to do is validate the submitted data on the server and refuse to proceed until your requirements are met.  Here's a page that shows the principle in action:
Mark BradyPrincipal Data EngineerCommented:
I recommend doing both. Use javascript on the front end to check the required fields. Javascript validation makes the whole form sending experience faster if there is a mistake. The form does not have to be sent via "submit" or an ajax call to the server and the server doesn't have to process the data and send back an error. It is convenience only.

Of course on the back end you absolutely should validate ALL data coming in especially if you are storing and retrieving from a database.

On the javascript (client side) just check the values of each input. ie: var x = document.getElementById('username').value;

if (x == '') {
    alert('Please fill out your username');

Go through any fields that must be filled out the same way always showing an error message of some sort then returning out of the function so the form is not sent.

Rather than use the traditional form submit you should consider using ajax to post your form data. It will avoid two page loads. When you 'submit' a form the browser loads the target script which processes the data then redirects the browser back to the website.

Ajax will send your data to the script (no page redirection) the script processes it and sends back a message to ajax. If there is an error sent back (missing information or something) the whole page does not need to reload. You just show the user what they missed. Very simple and fast.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
+1 for what Elvin66 writes here.  These might be useful links.  (Several useless links were deliberately omitted!)
StarThunderAuthor Commented:
Sorry for being so late in this... I had a health problem.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.