I have a email address field and 3 radio buttons. You must click one radio button and it will redirect you to another page. I am testing here If I can get the value of radio button (Category.val).
Here is my code:
<aui:script>
AUI().use(
'aui-modal','liferay-portlet-url','aui-io-request','aui-base',
function(A) {
$('a.btn-resetpass').click(function() {
var validator = $(".pwdLength"),
Category = $(".1");
if (validator.val().length != 0) {
alert(Category.val());
if (Category.val() == 1) {
}
else if (Category.val() == 2) {
}
else if (Category.val() == 3) {
}
//$('.resetForm').submit();
}
else {
alert ("Please input a valid email");
}
$('.resetForm').submit();
});
});
</aui:script>
Please help.
Thank you in advance!
The problem here is the selector used for radio buttons. You are trying to get all elements with class
1
, but if what you need is the selected radio so you have to use.1:checked
.Without the html it is difficult to form a proper selector, but assuming those are the only radio buttons in the page you can try
Update: As per your update the class used by you is
radioB
so