132
rated 0 times
[
135]
[
3]
/ answers: 1 / hits: 19700
/ 7 Years ago, fri, may 5, 2017, 12:00:00
I have HTML input box for phone numbers.
I'm using InputMask
to format input 860000000
in following 8 600 00 000
when typing.
$(window).load(function()
{
var phones = [{ mask: # ### ## ###}, { mask: # ### ## ###}];
$('#phone').inputmask({
mask: phones,
greedy: false,
definitions: { '#': { validator: [0-9], cardinality: 1}} });
});
I'm also using HTML pattern to check if numbers starts with 86
and there are total 9 digits, but with InputMask
it stopped working, and can't achieve It in any way:
<label for=phone class=first-col>Mobile No.:</label>
<input type=text id=phone placeholder=8 600 00 000 required pattern=(86)d{7} />
And CSS to add green borders if valid:
input:required:valid {
box-shadow: 0 0 5px #5cd053;
border-color: #28921f;
}
Have you any ideas?
There is JS Fiddle
More From » jquery