cannot insert special character in input type element.

cannot insert special character in input type element.

petitsingepetitsinge Posts: 11Questions: 1Answers: 0
edited March 2014 in General
This bug has been baffling me for couple of hours now.
I insert data dynamically from a jquery function that looks likes the example below.

http://live.datatables.net/Amec/4/edit?html,css,js,output

It actually takes tab separated values that are inserted into a text area.

My problem is that when there is special character like ' or " it will trunk the textbox value.
Like the values in Column 2 of the example.

I tried double escaping and even then as soon as it sees the ' character it removes the rest of the text.
Is there a way to insert the whole value without regard for for single or double-quotes?

Thanks


Yan

Replies

  • petitsingepetitsinge Posts: 11Questions: 1Answers: 0
    Looks like i had to create a new function to convert the special characters into html format.

    [code]
    function escapeHtml(unsafe) {
    return unsafe
    .replace(/&(?!amp;)/g, "&")
    .replace(/<(?!lt;)/g, "<")
    .replace(/>(?!gt;)/g, ">")
    .replace(/"(?!quot;)/g, """)
    .replace(/'(?!#039;)/g, "'");
    }
    [/code]
This discussion has been closed.