Skip to content
Advertisement

Giving deletable default value for masked phone number

I just want to use +90 as deletable (BACKSPACE) default value for area.

<input class="form-control phone" id="GSMNo" name="GSMNo" placeholder="GSM No" required="required" type="text" value="" aria-required="true" aria-invalid="true">

AREA

Control part

  $.validator.addMethod("phone", function (value, element) {
                var format = $(element).data('format'),
                    phoneFormat = format ? format : yap.settings.common.format.phone;
                return this.optional(element) || $.inputmask.isValid(value, { mask: phoneFormat });
            }, metaDic["PleaseEnterValidPhone"]);

My formatter part;

   format: {
                phone: '+\90 (A99) 999-9999',

            },

I will be grateful if anyone could help me.

Advertisement

Answer

I solved issue with using * character for each space.

 phone: '+**(A99) 999-9999',

for giving county code as default value.

var $inputGSM = $('#GSMNo'); //my area
     $(document).ready(function () {
                        var countryCode = "your country code"
                        var number = $inputGSM[0].value;
                        if (number == "") {
                           countryCode = "(" + countryCode + ")";
                    document.getElementById('GSMNo').value = countryCode;
                        }
                });
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement