Jump to content

Validating that all groups of radio buttions have been clicked


john2020

Recommended Posts

I have a form on a PHP page which has 11 groups of radio buttons.  Is there way to use PHP instead of client-side JavaScript to submit the form values only when one radio button has been selected from each of the 11 groups?

 

Also, is it possible to get the form elements in a PHP page with JavaScript?

 

Why does this JavaScript:

myForm.elements.length

stop working in a PHP page?  I thought it wouldn't affect client-side JS since PHP is server-side code.

 

Thank you!

Link to comment
Share on other sites

You should be validating server-side and not just checking with JS to begin with. JS is not validation. However it's impossible to say how without seeing the code.

 

For your second question, php doesn't cause any javascript to not work. You'd need to examine the underlying html source and see what's causing it.

Link to comment
Share on other sites

I agree that validation should be done server-side but this is a different scenario. In this case the users are a captive audience of inside company professionals and the only validation they want is that the form should be submitted once all of the questions has been answered by selecting a radio button answer. They don't want any other validation.

 

I have figured out how to submit the form with JavaScript after all the questions have been answered but I was wondering if PHP has a similar mechanism.  Perhaps,not because this seems to be a client-side issue unless AJAX is used to communicate with the server.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.