Hey everybody I want to let you know that I have undertaken the grueling task of getting the heck away from WordPress. I was so sick of the problems and updates I had to do all the time. I am now using my ezbloo system and I am integrating all my old posts into the new system. It sucks, but in the end, I will save bundles of time. I needed to keep things simple and that is why I created ezbloo. I'll have more on this later for you guys after I am done with the total integration of my old posts here. So if you are looking for a post and need it faster, shoot me an email and I will make it a priority. [email protected]

The number attribute in HTML5 may give you a warning, "Please Enter A Valid Value". Using decimals in HTML5 requires that you use an attribute of "step". Consider the following in the form tag element.

<input type="number" step="any" name="price">

Another

<input type="submit" value="submit">
<input type="number" name="price">
<input type="submit" value="submit">

This will result in a blank box.

Blank Number Box in HTML5

Blank Number Box in HTML5

When entering a decimal value into the box you may get a warning. After you click the submit button you will see something that looks like this.

Number Box in HTML5 With Warning

Number Box in HTML5 With Warning

HTML5 Input Default for Numbers

As you can see the default for HTML5 is whole numbers. In order to use a decimal you have to use a step attribute. See code below.

Other Examples of Step in HTML5

Here are some other examples of how you can use the step attribute.

<input type="number" step="1"> Whole Numbers
<input type="number" step="0.01"> Decimals
<input step="any" type="number"> Whole or Decimals
<input step="10" type="range"> Range of 10
<input type="submit">

When Processing Forms With Decimals

Remember that when you are processing forms with decimals you must have your database set up properly. For example if you want to use integers in your mySql database with decimals you must specify it.

Example of Specifying Decimal Integers in MySql

Use decimal(4,2) if you want to be able to store numbers like 1452.87 or xxxx.xx.

Example of Specifying Decimal Integers in MySql