jquery - if else statement has no effect - javascript -
i have bootstrap modal box contains signup form. i've added code makes modal box disappear when submit button pressed:
$(".dismiss-signup-modal").click(function () { jquery('#signup_modal').modal('hide'); } });
this works fine want make modal box stay if phone number field of signup form blank , disappear if phone number field has value, this:
$(".dismiss-signup-modal").click(function () { if ($('.signup-phone').length > 0) { jquery('#signup_modal').modal('hide'); } else {} });
but above code doesn't anything, modal box still disappears if phone number field left blank. i've tried every combination can think of placing if else statement outside function or creating new function or making .signup-phone var nothing works, ideas? thanks
you need check length of value..
but checking existence of jquery object (if element exists or not)
supposed
if( $('.signup-phone').val().length > 0 ) {
$('.signup-phone').length
greater one, since element pressnton page. condition true.
Comments
Post a Comment