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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:25:39+00:00 2026-06-10T14:25:39+00:00

I’m trying to create partial RegEx match in JS. What I want to achieve

  • 0

I’m trying to create partial RegEx match in JS. What I want to achieve is that when user enters something inside input field, JS will always do partial match for number sequence on key press, not only when whole RegEx match is fulfilled.

So, this is the RegEx rule:

^[12][^1-6]\d{2}$

When user enters number 1 or 2, that is correct match, but 3 is incorrect. Next, when numbers between 1 and 6 are not entered, that is also correct, and at last any 2 next numbers are correct. As I said, right now RegEx match is fulfilled only when all 4 numbers are entered.

How can I achieve partial input check?

  • 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-06-10T14:25:41+00:00Added an answer on June 10, 2026 at 2:25 pm

    Well, the easiest solution is to wrap optional components into the corresponding (?:)? construct. You actually have two optional components, so you need to take that into account.

    The result will look like…

    ^[12](?:[^1-6]\d{0,2})?$
    

    … as you have to match both ‘2x’, ‘2×1’, and ‘2×11’, it seems. ) Hence {0,2} quantifier.

    The problem obviously is that you cannot use a single regex to check whether a user finished entering some value into your field – or not. In other words, if you want the ‘intermediate’ 1 to match, but the resulting 1 not to match, well, it’s just impossible to do with a single regex check. )

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

Sidebar

Related Questions

I'm trying to create a form that will animate something while processing a particular
I am trying to create a partial view I call ImageViewer. It will be
I'm trying to create an MVC view that will display some data in a
I'm trying to create regular expression that filters from the following partial text: amd64
I'm trying to create a method that will send a PDF file directly to
I am trying to create controller actions which will return either JSON or partial
I'm trying to create a view that will create a subcategory. In order to
I am new to .net MVC structure. I am trying to create Partial view
Trying to create a simple custom control in C# Winforms that inherits from Panel,
I'm trying to create a very simple email signup form, where the user can

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.