An essay of search for one of these characters in strings...
Code:
// Multiple strings to split for tests
var str="hello word !@<script>@How are you ?@Well 5/5 !@2*2 = 4@...\"...@..|..@Good luck !".split('@');
// The test for one of the following characters: \/:*?"<>|
for (var l=str.length,i=0;i<l;i++)
alert(str[i]+(/[\\\/:\*\?\"<>]/.test(str[i])?' contains':' does not contain ')+' one of the indicated (\/:*?"<>|) characters !');
All this characters (except colon, less and more) must be escaped with a backslash in the character class delimiter by the two square brakets...
okay, is there a to put it in a if statement?(so after i validate if they typed something in or not i can check to see if they have a invalid characters entered.). Thank You For The Reply.
The caret (^) at the beginning forces the pattern to start at the beginning of the string.
The dollar sign ($) at the end forces the pattern to go all the way to the end of the string.
The dot-star-question-mark (.*?) sets allow us to ignore leading and trailing characters.
The square brackets ([]) surround multiple individual characters to seek.
Each of the individual characters is preceeded by a back-slash (\) so that it doesn't have any special meaning.
Bookmarks