I use such jquery.inputmask.bundle.js library. Tell me why required form doesn't work when submitting a form and +7 (32_) is inserted into placeholder ... and not +7 () ....?

<input type="text" id="phone" name="phone" placeholder="+7 (___) ___-__-__" minlength="6" required> $("input[name='phone']").inputmask("+7 (999) 999 99 99", { alias: 'phonebe', clearMaskOnLostFocus: false, onBeforeMask: function (value, opts) { var processedValue = value.replace(/^0/g, ""); if (processedValue.indexOf("32") > 1 || processedValue.indexOf("32") == -1) { processedValue = "32" + processedValue; } return processedValue; } }); 

    2 answers 2

    32 is inserted because you have written in the onBeforeMask method:

     if (processedValue.indexOf("32") > 1 || processedValue.indexOf("32") == -1) { processedValue = "32" + processedValue; } 

    Remove this condition and all. Regarding the required documentation, there is nothing in my opinion; this should be checked not with the help of this library, but on the side of the backend or another JS library.

      partially solved the problem with required by removing clearMaskOnLostFocus: false,