Anonymous Anonymous - 4 months ago
176 0

Should add dash if value is numeric after 7 chars

Javascript

Add dash

Embed
$(window).load(function(){
	$('#pasnummer').keyup(function (e) {
		if (e.which != 8 && e.which != 0 && (e.which > 48 || e.which < 57)) {
		
	    var inputLength = $(this).val().length;
	    
			switch (inputLength) {

	        case 7:
	            var currentValue = $(this).val();
	            var newValue = currentValue + '-';
	            $(this).val(newValue);
	            break;
	        default:
	            break;
			}
			
		}
		
	});
});
Comments