网页重写字符串val()方法的扩展获取安全参数String
时间:5年前 作者:庞顺龙 浏览:635 [站内原创,转载请注明出处]
//Val方法的扩展获取安全参数Objcet jQuery.fn.valSafe = function () { if ($(this).val() != undefined) { var str = $(this).val().toString(); return str.valSafe(); } else { return undefined; } }; //Val方法的扩展获取安全参数String String.prototype.valSafe = function () { var str = this; while (str.indexOf("'") > -1) { str = str.replace("'", """); //转化单引号 } str = encodeURIComponent(str); //encodeURIComponent加密 return str; } String.prototype.Trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); } String.prototype.LTrim = function () { return this.replace(/(^\s*)/g, ""); } String.prototype.RTrim = function () { return this.replace(/(\s*$)/g, ""); }
内容均为作者独立观点,不代表八零IT人立场,如涉及侵权,请及时告知。
本站文章除注明转载外,均为本站原创,欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创和谐网络社区。
转载请注明:文章转载自-八零IT人 [http://www.80iter.com]
本文标题:网页重写字符串val()方法的扩展获取安全参数String
本文地址:http://www.80iter.com/blog/1450313512153682
转载请注明:文章转载自-八零IT人 [http://www.80iter.com]
本文标题:网页重写字符串val()方法的扩展获取安全参数String
本文地址:http://www.80iter.com/blog/1450313512153682

暂无评论
暂无评论
手机扫码阅读
热门相关
