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!

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.