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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Form maxlength

  • 07-09-2010 8:32pm
    #1
    Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭


    I have a form on my page where I've set the maxlength to 20. All well and good, however, the client wants to be able to enter double quotes into that field now and then. If I just allow them to enter "Hello", then when I'm showing that value in the form field later, I'll get
    [PHP]<input type="text" value=""Hello"">[/PHP]
    which will result in at the very least an empty field. So I have a bit of encoding on the the php backend to handle the double quotes, converting it to ". This worked well until I entered
    [PHP]"This is 16 chars"[/PHP]
    This converts to
    [PHP]"This is 16 chars"[/PHP]
    and when written back to the form field becomes
    [PHP]"This is 16 cha[/PHP]
    because of maxlength limit

    So is there something I'm missing when it comes to encoding double quotes for size limited fields?


Comments

  • Registered Users, Registered Users 2 Posts: 207 ✭✭hobbit stomper


    Are you using PHP?

    Then you need to look into stripslashes.

    If you use MySQL you're better of looking into mysql-real-escape-string


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    I normally swap double-quotes with two single quotes to achieve this.


  • Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭corblimey


    hobbit, I'm using both, but the issue is less to with how the value is saved and more with how to display double quotes in form field. I could use " no issue but the size limitation is cutting it off.

    Liam, the two single quotes idea is a good one, although they still take up more room than one double quote, and the client will notice when modifying the field containing ''Hello'' rather than "Hello".


Advertisement