Chủ Nhật, 3 tháng 1, 2016

required bắt lỗi form html5

**** HTML
<input class="numberic" name="nhapso" type="text">

****Script: chỉ cho nhập số
                      <script type="text/javascript">
jQuery(document).ready(function($) {

$(".numberic").keypress(function(e){
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
$("#errmsg").html("Number").show().fadeOut("slow");
return false;
}
});
});
</script>

Không có nhận xét nào:

Đăng nhận xét