function Strips Tutorial Cript (s)
{
var pattern = new RegExp ("[' ~!@#$^&* () =|{} ':; ', \[\].<>/?~! @#¥......&* ()--| {}【】‘;:”“'。 ,、? ]")
var rs = "";
for (var i = 0; i < s.length; i++) {
rs = Rs+s.substr (i, 1). replace (pattern, ');
}
Return RS;
}
Method Two
* Verify that all input fields contain special symbols
* The symbols to be filtered are written to the regular expression, noting that some symbols are "escaped".
* The characters to be escaped include: 1, dot number.
* 2, bracket []
* 3, curly brace {}
* 4, plus +
* 5, Asterisk *
* 6, minus sign-
* 7, Slash
* 8, vertical bar |
* 9, pointed ^
* 10, Coin $
* 11, question mark?
* Test Example:
* IF (Checkalltextvalid (Document.forms[0]))
* Alert ("All text boxes in the form pass the checksum!") ");
*/
function Checkalltextvalid (form)
{
Record the number of text boxes that do not contain quotes
var resulttag = 0;
Record the number of all text boxes
var flag = 0;
for (var i = 0; i < form.elements.length i + +)
{
if (form.elements[i].type== "text")
{
Flagflag = flag + 1;
Here to fill in the special symbols to be filtered
Note: Modify the ### #处的字符, other parts are not allowed to modify.
if (/^[^####]*$/.test (Form.elements[i].value))
if (/^[^| "' <>]*$/.test (Form.elements[i].value))
Resulttagresulttag = resulttag+1;
Else
Form.elements[i].select ();
}
}
/**
* If a text box with quotes is equal to the value of all text boxes, the checksum passes
*/
if (Resulttag = = flag)
return true;
Else
{
Alert ("text box cannot contain 1 single quotes: ' 2 double quotes:" 3 Vertical bars: | 4 Sharp Corner Number: < > Please check the input! ");
return false;
}
}