Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Uneditable input field in Javascript

Options
  • 06-04-2004 9:55am
    #1
    Registered Users Posts: 3,548 ✭✭✭


    Anyone know how to make an input field in Javascript which cannot be edited by the user?


Comments

  • Closed Accounts Posts: 304 ✭✭Zaltais


    Disabled or Readonly?


    [PHP]
    Disabled:
    <INPUT disabled name="fred" value="stone">
    [/PHP]

    [PHP]
    Readonly:
    <INPUT readonly name="fred" value="stone">
    [/PHP]

    You can change this in Javascript with:

    document.formName.fred.disabled = "False"
    document.formName.fred.readonly = "False"

    This funcionality is not consistient across all browsers though so test before you implement


  • Registered Users Posts: 3,548 ✭✭✭Draupnir


    Cheers, worked a treat.


  • Closed Accounts Posts: 235 ✭✭Yerac


    Just be careful with it if you are using for cgi scripts or similar. It can be over-ridden , expecially if not compatible in all browsers.
    If you are submitting the value to a script of some sort, make sure to validate at server end too.


Advertisement