Skip to content

InputNumber: don't allow users to type more than 6 digits / chars. #7627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 4 tasks
HarshilPatel007 opened this issue Apr 21, 2025 · 2 comments
Closed
1 of 4 tasks
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@HarshilPatel007
Copy link

Describe the bug

hello guys,

Is there any way we can restrict users from entering more numbers than defined?
Use case:
I want to input ID CARD NUMBER. And it's a 6 digit only CODE. ex. 223344. Not 22334455. ← Don't allow this.

I don't want to use inputMask as it shows the ___ underscores. I just want plain simple number input where user can type only 6 digit / char long number. not more than that.

<template>
  <ThemeSwitcher />
  <div class="card flex flex-wrap gap-4">
    <div class="flex-auto">
      <label for="minmax" class="font-bold block mb-2">
        User can enter Max 5 digits.
      </label>
      <InputNumber
        v-model="value4"
        inputId="minmax"
        :min="0"
        :max="5"
        :useGrouping="false"
        fluid
      />
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';

const value4 = ref(50);
</script>

Pull Request Link

No response

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

No response

Reproducer

https://stackblitz.com/edit/fzh8fs51?file=src%2FApp.vue

Environment

deps.

    "@primeuix/themes": "^1.0.1",
    "@primevue/forms": "^4.3.3",
    "@tailwindcss/vite": "^4.1.3",
    "lucide-vue-next": "^0.487.0",
    "pinia": "^3.0.1",
    "primevue": "^4.3.3",
    "tailwindcss": "^4.1.3",
    "tailwindcss-primeui": "^0.6.1",
    "vue": "^3.5.13",
    "vue-router": "^4.5.0",
    "zod": "^3.24.3"

dev deps.

    "@tsconfig/node22": "^22.0.1",
    "@types/node": "^22.14.0",
    "@vitejs/plugin-vue": "^5.2.3",
    "@vue/eslint-config-prettier": "^10.2.0",
    "@vue/eslint-config-typescript": "^14.5.0",
    "@vue/tsconfig": "^0.7.0",
    "eslint": "^9.22.0",
    "eslint-plugin-vue": "~10.0.0",
    "jiti": "^2.4.2",
    "npm-run-all2": "^7.0.2",
    "prettier": "3.5.3",
    "typescript": "~5.8.0",
    "vite": "^6.2.4",
    "vite-plugin-vue-devtools": "^7.7.2",
    "vue-tsc": "^2.2.8"

Vue version

^3.5.13

PrimeVue version

^4.3.3

Node version

No response

Browser(s)

No response

Steps to reproduce the behavior

type in input field.

Expected behavior

It should not allow users to type more than 6 digits / chars

@HarshilPatel007 HarshilPatel007 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 21, 2025
@rajithaeyee
Copy link

rajithaeyee commented Apr 21, 2025

@HarshilPatel007 according to the API for InputNumber, you could simply set a min and max boundaries, for example if your ID needs 6 digits, The smallest 6-digit number is: 100000 and
The largest 6-digit number is: 999999. I guess this way you could achieve what you are expecting.

@cagataycivici
Copy link
Member

Please use Discord and Discussions for questions and help requests, instead of the issue tracker.

https://github.com/orgs/primefaces/discussions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

3 participants