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 6854627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:39:25+00:00 2026-05-27T01:39:25+00:00

I have an input that will have input between 3-5 alphanumeric characters. I want

  • 0

I have an input that will have input between 3-5 alphanumeric characters.

I want to validate that the user input between 3-5 characters:

/^[A-Za-z0-9]{3,5}$/

But, I want to ignore any alpha characters on form submission, not strip them.

So an input value of "RS032" stays that way in the input on form submission, but the form only actually returns "032"

  • 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-27T01:39:25+00:00Added an answer on May 27, 2026 at 1:39 am

    The question is a little shy of details, but I’m guessing you want to validate everything in the field except letters. So, if the input is abc1d2e3fgh and your requirement is 3 digits, you want that to pass.

    For a very basic requirement like this, you can intersperse optional [A-Za-z]*? sets between the other required characters. So, for the 3-numbers requirement, you could use

    [A-Za-z]*?\d[A-Za-z]*?\d[A-Za-z]*?\d[A-Za-z]*?

    This requires 3 digits (\d), and allows any number of letters before, between, or after those digits.

    If you need to use match/capture groups, instead of just verifying match/no-match this won’t work.

    Unless you have a very basic requirement, there is no way that I know of to achieve this with a single RegEx. You’ll likely need to assign the string to another variable, strip the letters, and then validate. By assigning to another variable, you can leave the input in place.


    Update in response to question edit:

    It sounds like you do want to strip the letters, only you want to do it in the backend. I think that is exactly what you should do, instead of conflating that with validation.

    If you really want to do the work client-side, you could use an additional, hidden field, that you update via Javascript when the "source" text changes. On the server you can ignore the "source" field and instead use the "stripped" one.

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

Sidebar

Related Questions

I have the following code that basically is a input form as I have
I have an input that takes tag names, with a space between them. Then
Basically, I'd like to have an input that when blur'd, will check the input
I have an HTML form that needs multiple submit buttons, like this: <input type=submit
I'm writing some javascript (a greasemonkey/userscript) that will insert some input fields into a
I have the input of a gamepad thumbstick that's a vector. The range of
I have a string that will look something like this: I'm sorry the code
I have the following code that will count the elapsed time and print the
Situation: I have a function that dumps input data into an HTML block element,
I challenge you :) I have a process that someone already implemented. I will

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.