Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Uneditable input field in Javascript

  • 06-04-2004 08:55AM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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
Advertisement