CP_phone_number
CP_phone_number
by bryiantan
HTML
<input type="text" id='txtPhone'>
JavaScript
var tempPhone = '';
$("#txtPhone").keyup(function (e) {
if($(this).val().match(/^\+?\d{0,}$/))
{
tempPhone = $(this).val();
$(this).val( tempPhone);
}
else {
$(this).val( tempPhone);
}
});
//paste, clear the temp value
$('#txtPhone').on('paste', function () {
tempPhone = '';
});