Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4018782
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:01:31+00:00 2026-05-20T10:01:31+00:00

i need to validate address1 , address 2 and city using jquery regex.. Used

  • 0

i need to validate address1 , address 2 and city using jquery regex..

Used for a street address. Legal Characters: A-Z, a-z, 0-9, hyphen, slash and single space. Illegal Character: leading space, trailing space, adjacent spaces, and other symbols.

Used for a city. Legal Characters: A-Z, a-z, and single space. Illegal Character: leading space, trailing space, adjacent spaces, and symbols.

sample:

Address1: { required: true, regex: “A-Za-z0-9*” }

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:01:32+00:00Added an answer on May 20, 2026 at 10:01 am

    I assume you’re doing this for some project, so you should really figure out how to do the regex on your own.

    However, I will tell you. It is my understanding that you need to give the regex for each field separately and they will be validated separately.

    //Address 1 & 2 regex
    regex: /^[a-zA-Z0-9-\/] ?([a-zA-Z0-9-\/]|[a-zA-Z0-9-\/] )*[a-zA-Z0-9-\/]$/
    

    Start with a letter/number/dash/slash followed by an optional space. Follow with any number of l/n/d/s or l/n/d/s followed by a space (this forces there to be only one space because each space must be preceded by a l/n/d/s). End with l/n/d/s.

    //City is much easier:
    regex: /^[a-zA-z] ?([a-zA-z]|[a-zA-z] )*[a-zA-z]$/
    

    Pretty much the same as above, just without worrying about numbers, dashes, and slashes.

    Check out unit tests: http://jsfiddle.net/LJCzR/4/

    As stated above, though if you are not doing this for academic reasons, then I wouldn’t validate on leading/trailing space or duplicate space at all. I would silently clean it. Additionally, you simply can’t account for every case. This kind of validation is just annoying.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to validate the duplicate of FirstName, LastName and Email Address combination using
I need to validate the email address that are semicolon separated using ListView. e.g.
I need to validate the email address of my users. Unfortunately, making a validator
I don't need to validate that the IP address is reachable or anything like
I need to validate an email address which was in the format dsfdsf@.fdsf.com As
Possible Duplicate: Regular expression to match hostname or IP Address? I need to validate
I need to validate an email address which will be transmitted to several possible
I need to validate email addresses which can be single or several comma-separated ones.
i need to validate that an inserted email address contains @ and . without
I need to validate a email address the best way, and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.