Mobile number format(111-111-1111) and maxlength=12(check)using javascript in Jquery mobile in phonegap applied for both Android and IOS.
here i used keyup() and onblur() functions
keyup()function
$('.mobilenumber111').keyup(function() {
this.value = this.value
.match(/\d*/g).join('')
.match(/(\d{0,3})(\d{0,3})(\d{0,4})/).slice(1).join('-').replace(/-*$/g, '');
});
onblur() function
function checkno1()
{
var x=document.getElementById("mobilenumber").value;
//alert(x.length);
if(x.length < 12)
{
navigator.notification.alert(
'Enter valid number', // message
alertDismissed, // callback
'Sign in', // title
'Ok' // buttonName
);
$("#mobilenumber").val("");
}
}
<input type="tel" name="number" class="mobilenumber111" value="" onblur="checkno1()" placeholder="Mobile Number" maxlength="12" data-role="none" required/>
1 comment:
I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article. 333 angel number
Post a Comment