TacomaVA
asked on
Disabling changes to a form field
I have a simple form setup and I'm using PHP to read the form and send the data to a text file. I only want the user to able to modify a few of the fields. The rest I've set to have values. I want to set my page up so that the user can not modify the fields that already have values. Here's what I tried:
<input type="text" name="Field1" size="30" maxlength="2" value="H0" id="Field1" disabled />
The disabled prevents the user from entering anything into the field and the field still shows my value of H0. However, PHP doesn't see any text in the field and therefore does not store anything to my text file.
So is there a simple CSS/JS script I could use to stop users from entering characters into specific fields?
<input type="text" name="Field1" size="30" maxlength="2" value="H0" id="Field1" disabled />
The disabled prevents the user from entering anything into the field and the field still shows my value of H0. However, PHP doesn't see any text in the field and therefore does not store anything to my text file.
So is there a simple CSS/JS script I could use to stop users from entering characters into specific fields?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If not, you can have your textbox watch for any keyboard strokes, and return null each time. Not sure exactly how that would be coded, but it's not easy. I've done something similar, but a LONG time ago.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, both of you! Both solutions worked!
Thanks for the points! Happy new year!