Keeping users from messing up entry

Discussion in 'Programming' started by Site Owner, Jul 27, 2007.

  1. #1
    With help from a fellow user on here, we created this cool textbox which you can test here: http://www.freewebs.com/moreauctions/addtext.html

    As you can see it adds a linebreak after each text is added. It is meant to create a list to be output from a form. But a user can click inside the textarea and mess up the list and enter anyway they want.

    How can I make sure that there is always a linebreak between each line of text?
    
    <input size="20" id="inputtext">
    <input name="add" value="Add" onclick="document.getElementById('textarea').value+='•'+inputtext.value+'\n\n';" type="button">
    <textarea rows="15" id="textarea" name="box" cols="22"></textarea>
    Code (markup):

     
    Site Owner, Jul 27, 2007 IP
  2. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #2
    You can use a readonly attribute on the <textarea>. How important is it that users do not edit the contents of the textarea?
     
    krt, Jul 27, 2007 IP
  3. Site Owner

    Site Owner Peon

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I was thinking of that but I realized users need to be able to delete from the textarea.
     
    Site Owner, Jul 27, 2007 IP
  4. Site Owner

    Site Owner Peon

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Wait I think this can be done with createTextRange() but I have no idea.
     
    Site Owner, Jul 27, 2007 IP