I am trying to detect in ajax what is an empty field. ( echo $field;→> output - radios)
This one if (!data.livre && data.livre == "radios") {checks to see if it is data.livreinvalid (this works) and now I want to check if the radio echo is or not. If this is a radio, I showed the user: empty radio stations
function check($form) {
$fields = array("radios", "age");
foreach($fields as $field) {
if(empty($form[$field])) {
echo $field;
return false;
}
}
return true;
}
$data = array();
$data['livre'] = $val-> check($form);
echo json_encode($data);
JSON Output:
radios{"livre":false}
js
success: function(data) {
if (!data.livre && data.livre == "radios") {
$("#msgbox1").fadeTo(200, 0.1, function() {
$(this).html('empty radios').addClass('messageboxerror1').fadeTo(900, 1);
});
}
}
EDIT. What is the best way to determine if an empty field is radio or age?
thank
source
share