Ranbir Singh Ranbir Singh - 10 months ago 73
jQuery Question

Check minimum characters of street address using jQuery

I have a jQuery function to check the numeric characters in a zip code. I also need to check the minimum number of characters (10) of a street address.

function paymentStep1(){

jQuerychk = jQuery.noConflict();
var numbers = /^[0-9]+$/;
var zip = jQuerychk("input#id_billing_detail_postcode").val();
if (zip.match(numbers)) {
document.getElementById("errormsssgen").innerHTML = '';
document.getElementById("errormsssgen").innerHTML = "ZIP code must have numeric characters only."
return false;

Answer Source

Validate Street Address for a minimum of 10 characters:

function validateStreetAddress(value){
  var l = value.trim().length;
  if (l < 10) {
    alert("Error: Street Address must be a minimum of 10 characters!");
    return false;