I've been having a little problem with one of my input boxes in a form . It seems that my code doesn't like '0' being entered. Zero does not equate to '0.00' in PHP and this must be throwing an error somewhere.
However other number are fine; like '1' does not need to be entered as '1.00' .
php 0 to 0.00 conversion problems
php 0 does not equal 0.00
joomla component development how to force decimal input
php force decimal input in form
The quickest way to solve this problem for me was to write a bit of javascript takes that input box - and if the entered value is '0' - then change it to '0.00' . Here's the code.
var x=document.forms["myForm2"]["hourly_rate"].value;
if (x==0)
{
document.forms["myForm2"]["hourly_rate"].value='0.00';
return;
}
with the form being something like
< form name="myForm2" method="post">
Hourly Rate* :
< /form>
No comments:
Post a Comment