I am trying to validate a textarea text field for international characters (i.e. Japanese, Chinese, Urdu, French, English etc etc).
I am doing a validation script in jQuery file for a HTML field.
var regEx = / insert something in here /;
var tx = $('textarea');
for (var x = 0; x < tx.length; x++){
{
if ( !regEx.test( tx.eq(x).val() ) )
{
console.log('regex failed');
} else console.log('regex ok');
}
Getting that regEx is proving to be a little tricky as some regEx appear to be language specific? Any suggestions on a jQuery RegEx for the above code?
thx!
Karen
It’s a description area where customers describe a service they want.
I want to allow all international languages but no “harmful” characters (pardon as I am not entirely sure what those are) I am thinking no < > but otherwise any guidance as to alternative to regex or pointers as to what to strip out (maybe Html entities in php) or a good way to sanitize the data would be helpful for jQuery.
Personally I wouldn’t worry all that much about using JavaScript to sanitize user input in the browser client-side. Validate to help catch honest mistakes, yes, but a malicious user can easily “unsanitize” the input.