I have all kinds of form elements in a form. I have set mandatory class for mandatory elements to validate if they are not empty. The class selector works on input(text), textarea and select but not working on checkboxs and radios.
I know how can I check for at least one selection in a radiogroup or checkbox group (this answer) but I`m looking for a more general method to work only with class.
My exact question: Is there a general way to check all fields (and radios or checkboxes at least one selection) or I have to check radios and checkboxes separately?
my current code for inputs,textarea and select:
$(".ajaxform").ajaxForm({
beforeSubmit : function(arr, $form, options){
var myresult=true;
$(".mandatory").each(function(){
if (!($(this).val())){myresult=false}
});
return myresult;
},
success:showResponse
});