javascript - jquery check if input text empty is not working -
i have jquery code
if (($("#rdbdaterange").is(':checked')) && (!$("#cldrfrom").val()) && (!$("#cldrto").val())) {}else{} rdbdaterange id radio button. cldrfrom id input text cldrto id input text.
i want when radio selected and both of inputs not empty.
but code go inside if when inputs empty.
why please?
use .length property, spaces can use $.trim()
if ($("#rdbdaterange").is(':checked') && $.trim($("#cldrfrom").val()).length && $.trim($("#cldrto").val()).length){}else{} or,
you can use .trim(), note: function supported in ie9+
if ($("#rdbdaterange").is(':checked') && $("#cldrfrom").val().trim().length && $("#cldrto").val().trim().length){}else{} edit
as per requirement the radio selected , both of inputs not empty
you don't need !, remove it
Comments
Post a Comment