1

I am looking for the right pattern allowing to validate french numbers (positive integers) in an HTML input.

i.e. thousand separator is a "space".

Ex. of correct values:

  • 1
  • 12 345
  • 1 234 567
  • Ex. of incorrect:

  • 12x
  • 2x1
  • 1237
  • I have tried the pattern bellow, but it does not work

    <input pattern="([0-9]*[ ]*)*"/>

    Thanks for your help

    bart
    • 1,003
    • 11
    • 24
    Iznogood1
    • 152
    • 2
    • 11

    1 Answers1

    1

    try this -

    <input pattern="[0-9 ]+"/>
    

    Note: there is a space before ]

    in javascript you can get actual number by replacing all " "(spaces) with "" and converting the string to integer

    Thomas
    • 478
    • 4
    • 14
    • do accept my answer if found useful (the tick on the left side of my answer) – Thomas Jul 07 '19 at 13:39
    • Please do not add a comment on your question or on an answer to say "Thank you", instead accept the most helpful answer => https://stackoverflow.com/help/someone-answers – Thomas Jul 08 '19 at 09:43