Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Uneditable input field in Javascript

  • 06-04-2004 09: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