开发者

html input field, cleanse of bad characters on paste?

开发者 https://www.devze.com 2023-02-20 08:33 出处:网络
we run a web2print solution, that some people fill out a form to update some artwork. The problem is some users paste in text from word or other programs, and get weird dashes, spaces etc that aren\

we run a web2print solution, that some people fill out a form to update some artwork.

The problem is some users paste in text from word or other programs, and get weird dashes, spaces etc that aren't 开发者_运维知识库a part of normal keyboard input.

What we want to do is restrict the input to all the "normal" keyboard keys, not the unmapped character codes. How do we do this?

Many thanks,

b


I would create an array or something of all keyboard keys and then remove all chars that don't match.


You can use encodeURIComponent(value) function. It outputs safe coded UTF8 strings.

0

精彩评论

暂无评论...
验证码 换一张
取 消