jquery array how to get a key that has an empty value -
i have array keys , values pair.
i'm checking if there key has empty value , if know how key :
$(form).on('submit',function() { var arr = {}; var elemrequired = $(this).find('input:not(input[type=button], input[type=submit], input[type=reset]),textarea,select,checkbox').filter(':visible'); $('.error').empty(); elemrequired.each(function(i, el) { arr[el.id] = el.value; }); $.each(arr, function(id, val) { if (val == ""){ /*here want id has empty value*/ id.addclass('invalid'); }else{ } }); homecoming false; }); i know ther might other way want know if there's way that
thanks help
put
$('#'+id).addclass('invalid'); instead of this
id.addclass('invalid'); jquery
No comments:
Post a Comment