How to use jQuery validation to set the search bar to accept only a specific input?
This code does the job (there is p instead of a) jQuery(function(){ jQuery(“.search-submit”).click(function(){ jQuery(“.error”).hide(); var hasError = false; var searchReg = /^[p0-9]+$/; var searchVal = jQuery(“.search-field”).val(); var searchLen = searchVal.length; var num1 = [‘1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9’]; var num0 = [‘0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9’]; if(searchLen < 3) { jQuery(“.search-field”).after(‘<span class=”error”>Enter at least 3 characters.</span>’); hasError = true; } else if(searchLen > … Read more