1. 程式人生 > >input輸入框手機號碼344顯示

input輸入框手機號碼344顯示

keycode cti inpu 手機 fun length blog temp clas

                        // 手機號碼3/4/4顯示
			$(‘.section .inp‘).eq(0).on(‘keyup‘,function (e) {
				var backSpaceCode = e.keyCode;
				var temp = ‘‘;
				var str = ‘‘;
				if( backSpaceCode != 8 && $(this).val().length == 4 ){
					str = $(this).val().slice(3);
					temp = $(this).val().slice(0,3);
					$(this).val( temp + ‘ ‘ + str )
				}else if( backSpaceCode != 8 && $(this).val().length == 9 ){
					str = $(this).val().slice(8);
					temp = $(this).val().slice(0,8);
					$(this).val( temp + ‘ ‘ + str )
				}
			})            

  

input輸入框手機號碼344顯示