Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery maskedinput. How to check availability of the mask

Can anyone help me with checking availability of the mask. I use this one:

if ($.isFunction($("#ID").mask)){
    var val = $("#ID").mask();
} else {
    var val = document.getElementById(ID).value;
}

but this condition is always TRUE. Don't matter written with:

$(document).ready(function(){
  $("#ID").mask("8 (999) 999-9999");
}

or not.

like image 473
Silekin Sergey Avatar asked Sep 06 '25 03:09

Silekin Sergey


1 Answers

If you're trying to verify if the .mask() function is available, you should try checking $.fn.mask.

If you're trying to verify whether an element has a mask, test if $("#element").data("rawMaskFn") is defined.

like image 105
gustavohenke Avatar answered Sep 08 '25 00:09

gustavohenke