简体   繁体   中英

Javascript Escape Characters

I have kind of a lazy form that has two textboxes. When I click a button I basically concatenate the two textboxes with a delimiter. Is there like a special delimiter that cannot actually be typed in an html textbox, even if the &#xxx; syntax is used?

No, if you want to disallow characters you'll have to add some sort of javascript to prevent them being entered. Or just remove them from each field before joining.

Why concatenate? How about using JSON?

A simple and safe concatenation format would be

<length of the first string> <space> <first string> <second string>

For example

'abcd' + 'foo' => '4 abcdfoo'

可以在文本字段中键入任何内容,这就是为什么清理所有用户输入如此重要的原因。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM