php - disable if input value is text and enable if it number -


i want : if value of input text, disable. if value of same input number ,then enable.

the code is

 <input type="text" value ="<?php echo $row [0];? disable> 

this test if value int (cases 1.0 or '1' disabled) :

<input type="text" value="<?php echo $row[0];?>"<?php echo !is_int($row[0]) ? ' disabled="disabled"' : ''; ?> /> 

this test if value float (cases 1 or '1' disabled) :

<input type="text" value="<?php echo $row[0];?>"<?php echo !is_float($row[0]) ? ' disabled="disabled"' : ''; ?> /> 

this test if value int or float or numeric string (cases '1' enabled) :

<input type="text" value="<?php echo $row[0];?>"<?php echo !is_numeric($row[0]) ? ' disabled="disabled"' : ''; ?> /> 

Comments

Popular posts from this blog

php - trouble displaying mysqli database results in correct order -

depending on nth recurrence of job in control M -

sql server - Cannot query correctly (MSSQL - PHP - JSON) -