简体   繁体   中英

Charset validation in web text field

I need to limit character input in a text field (using ASP.Net/JavaScript/JQuery) to only allow characters in the ISO/IEC 8859-1 charset.

How would I do this?

Just set the charset of the page to ISO-8859-1 using <meta charset="ISO-8859-1"> then use a regexp like the following [\\x20-\\x7E\\xA0-\\xFF] . The regex will match any visible characters from ISO-8859-1

This answer shows how to restrict input based on regex.

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