I am doing a validation of 2 radios buttons, where depending on which one the selected form forwards to a different page. I'm using Jquery, as below:
jQuery(document).ready(function($) {
var form = $('form[name="cadastro"]'),
radio = $('input[name="MERCADO"]'),
choice = '';
radio.change(function(e) {
choice = this.value;
if (choice === "ME") {
form.attr('action', 'Checklist-P1-ME.php');
} else {
form.attr('action', 'Checklist-P1.php');
}
});
});
The radios are these:
<input type="radio" name="MERCADO" value="MI" CHECKED/>MERCADO INTERNO<br><br>
<input type="radio" name="MERCADO" value="ME" />MERCADO EXTERNO<br><br><br>
But what happens is that Jquery only recognizes the MI value if I click on the ME and then click back on the MI. It's as if it does not recognize the checked
predefined.
Any suggestions?