sleepyw Posted November 16, 2015 Share Posted November 16, 2015 I'm using the frmvalidator.addValidation code (with the associated validator.js file) and I cannot for the life of me find anywhere how to include an allowable character of a line break to the regexp. For example, I might have something like: frmvalidator.addValidation("Notes","regexp=^[A-Za-z0-9\u005F\ \.\-\@\,\%\*\!\?\$\&\'\#\+\=\:\;\(\)\u2022]{1,300}$","Notes can only contain the following non-alphanumeric characters: ,'?!/*&%$#@:;_+=@"); But if a user enters a line break, it won't accept it. I've tried adding \u000D, \u000A, \u000C, U+000D, \r\n, \n ..... nothing works. Am I missing something really obvious? Quote Link to comment https://forums.phpfreaks.com/topic/299494-frmvalidatoraddvalidation-regexp-for-a-line-break/ Share on other sites More sharing options...
Solution requinix Posted November 16, 2015 Solution Share Posted November 16, 2015 \r and \n are easier than the \u syntax, but they'll be interpreted by Javascript and you'll get those characters inside the actual string. Escape the backslashes like "\\r\\n". Quote Link to comment https://forums.phpfreaks.com/topic/299494-frmvalidatoraddvalidation-regexp-for-a-line-break/#findComment-1526495 Share on other sites More sharing options...
sleepyw Posted November 16, 2015 Author Share Posted November 16, 2015 (edited) \r and \n are easier than the \u syntax, but they'll be interpreted by Javascript and you'll get those characters inside the actual string. Escape the backslashes like "\\r\\n". Hi again requinix! OK...I need to edit my post. It actually did work, but now the bullet point character is not being accepted when it previously was (I think that's the \u2022). Edit #2: I moved the \u2022 up further into the regexp and it's working now. Run into this a lot where the order is critical, but not sure what the order is supposed to be. Thanks again for your help! Edited November 17, 2015 by sleepyw Quote Link to comment https://forums.phpfreaks.com/topic/299494-frmvalidatoraddvalidation-regexp-for-a-line-break/#findComment-1526499 Share on other sites More sharing options...
requinix Posted November 17, 2015 Share Posted November 17, 2015 Order does not actually matter. What did you have that wasn't working and what do you have now? Quote Link to comment https://forums.phpfreaks.com/topic/299494-frmvalidatoraddvalidation-regexp-for-a-line-break/#findComment-1526501 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.