- < script type = "text/javascript" >
- //==================================
- // xxx-xxx-xxxx Phnoe No Validation
- //==================================
- jQuery(document).ready(function() {
- $("#phone").keydown(function(e) {
- // Allow: backspace, delete, tab, escape, enter and .
- if ($.inArray(e.keyCode, [46, 8, 9, 27, 13]) !== -1 ||
- // Allow: Ctrl+A
- (e.keyCode == 65 && e.ctrlKey === true) ||
- // Allow: home, end, left, right, down, up
- (e.keyCode >= 35 && e.keyCode <= 40)) {
- // let it happen, don't do anything
- return;
- }
- // Ensure that it is a number and stop the keypress
- if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
- e.preventDefault();
- }
- var curchr = this.value.length;
- var curval = $(this).val();
- if (curchr == 3) {
- $("#phone").val(curval + "-");
- } else if (curchr == 7) {
- $("#phone").val(curval + "-");
- }
- });
- }); < /script>
10 Aralık 2015 Perşembe
Phone No (xxx-xxx-xxxx ) Validation in JQuery
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönder