breeze351
asked on
How do I set up an input (text pattern) for a dollar field
I have a page where I'm getting data from a previous page. The field is a monthly rental and therefor is #####.##. The data being passed is "250.00". I originally had the field as a numeric but that displays "250". I've tried several different "patterns" that i googled but they didn't work as advertised.
The code that I'm currently running is:
echo '<input type="number" pattern = "0.00-99999.99 {8}" title = "Enter a dollar amount without commas" name="$PSF" size = "8" min = "0.00" max = "99999.99" value="';
echo $work;
echo '" maxlenghth="8" step = "0.01">';
The source code in the browser reads as:
<input type="number" pattern = "0.00-99999.99 {8}" title = "Enter a dollar amount without commas" name="$PSF" size = "8" min = "0.00" max = "99999.99" value="250.00" maxlenghth="8" step = "0.01">
Thanks for the help
Glenn
The code that I'm currently running is:
echo '<input type="number" pattern = "0.00-99999.99 {8}" title = "Enter a dollar amount without commas" name="$PSF" size = "8" min = "0.00" max = "99999.99" value="';
echo $work;
echo '" maxlenghth="8" step = "0.01">';
The source code in the browser reads as:
<input type="number" pattern = "0.00-99999.99 {8}" title = "Enter a dollar amount without commas" name="$PSF" size = "8" min = "0.00" max = "99999.99" value="250.00" maxlenghth="8" step = "0.01">
Thanks for the help
Glenn
ASKER
That worked. But how do I let the user add commas to the field? Is there a site that I can learn how the "pattern" works?
Glenn
Glenn
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Got it.
Thanks
Thanks
input type="text" pattern="^\d*(\.\d{2}$)?"
Here are some examples of dealing with this problem.
http://jsfiddle.net/NfMQ7/178/