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

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -