Tuesday, 15 May 2012

php - Enforce limit on numeric input. -



php - Enforce limit on numeric input. -

so have this:

<input name="data[donation][amount]" value="0.00" step="any" maxlength="12" type="number" id="donationamount">

my question how create absolutely sure no negative numbers set field? if possible secure on both , front end ends.

thanks.

on client side can test javascript like

var num=123.45; $("#donationamount").val().match(/^[0-9.]+$/)

and on server side can check like

$num = "100"; if ( (int)$num == $num && (int)$num > 0 )

php html css

No comments:

Post a Comment