Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Price input pattern html5

Tags:

html

regex

grails

I've got input field and I want to check dot existence for value of price input field. The value will be look like this 12.00. Here is my code

<g:textField class="span3" id="price" name="price" required="" pattern="\d+(\.\d{2})?"/>

I write something like this \d+(\.\d{2})?, but received error. Any suggestions ?

like image 956
emilan Avatar asked Oct 22 '25 09:10

emilan


1 Answers

try this

[0-9]+(\\.[0-9][0-9]?)?

<form>
  <input type='number' pattern='[0-9]+(\\.[0-9][0-9]?)?' />
  <button type='submit'>Check</button>
</form>
like image 177
Aram Arabyan Avatar answered Oct 25 '25 08:10

Aram Arabyan