jquery validation for allow alphanumeric with maximum and minimum length

In this post we will show you jquery validation for allow alphanumeric with maximum and minimum length, hear for jquery validation for allow alphanumeric with maximum and minimum length we will give you demo and example for implement.

jquery validation for allow alphanumeric with maximum and minimum length

Hear is jquery validation for allow alphanumeric with maximum and minimum length. we will give you jquer code for allow only alphanumeric and maximum and minimum length 15.

jQuery('#referrer_val').bind('keydown', function (event) {
	var maxLength = jQuery(this).val().length;
	switch (event.keyCode) {
		case 8:  // Backspace
		case 9:  // Tab
		case 13: // Enter
		case 37: // Left
		case 38: // Up
		case 39: // Right
		case 40: // Down
		break;
		default:
		// allow A to Z, a to z and 0 to 9
		var regex = new RegExp("^[a-zA-Z0-9.,/ $@()]+$");
		var key = event.key;
		if (maxLength >= 15) 
		{
			return false;
		}
		else
		{
			if (!regex.test(key)) 
			{
				event.preventDefault();
				return false;
			}
		}
		break;
	}
});

Hope this code and post will helped you for implement jquery validation for allow alphanumeric with maximum and minimum length. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs onlincode.org