regular expression that accepts numbers from 0-9 and the $ sign

0

I'm trying to make a text-type field only accept this format

<input type="text" class="form-control s18 no-pad displayInlineBlock" id="tarifa" name="tarifa" maxlength="30" required pattern="[^a-zA-Z0-9]">

example: $ 12,000.00 So far he only accepts me from 0-9

    
asked by Pedro Misael Canche Angulo 15.06.2018 в 20:46
source

1 answer

1

Use this regular expression ^[0-9,$]*$ to allow only numeric values to be sent in the input along with a dollar or weight sign.

<input type="text" name="text" pattern="^[0-9,$]*$">

If you want to add a personalized message for the error that produces html5 use a 'title' within the input with your message

    
answered by 15.06.2018 в 21:03