<input type="text" placeholder="Enter values" class="num_only" required>
<p class="altMessage"></p>
<script>
$(document).on('keypress','.num_only',function(event){
return isNumberKey(event);
})
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if(charCode == 46 ) {$('.altMessage').css('display', 'block');
$('.altMessage').fadeOut(2000); return false;}
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57)){
$('.altMessage').css('display', 'block');
$('.altMessage').fadeOut(2000);
return false;
}
return true;
}
</script>
<p class="altMessage"></p>
<script>
$(document).on('keypress','.num_only',function(event){
return isNumberKey(event);
})
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if(charCode == 46 ) {$('.altMessage').css('display', 'block');
$('.altMessage').fadeOut(2000); return false;}
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57)){
$('.altMessage').css('display', 'block');
$('.altMessage').fadeOut(2000);
return false;
}
return true;
}
</script>
0 comments:
Post a Comment