js实现基于正则表达式的轻量提示插件
作者:bea
本文实例讲述了基于正则表达式的轻量提示插件,分享给大家供大家参考。具体如下: 这是一款javascript实现基于正则表达式的轻量提示插件,本插件是基于正则表达式进行文本框检测的,通用性十分强,大家可以在实例中进行使用。 运行效果图: -------------------查看效果------------------- 小提示:浏览器中如果不能正常运行,可以尝试切换浏览模式。 关键代码: $(document).ready(function () {
本文实例讲述了基于正则表达式的轻量提示插件,分享给大家供大家参考。具体如下: 这是一款javascript实现基于正则表达式的轻量提示插件,本插件是基于正则表达式进行文本框检测的,通用性十分强,大家可以在实例中进行使用。 运行效果图: -------------------查看效果-------------------
小提示:浏览器中如果不能正常运行,可以尝试切换浏览模式。 关键代码:
$(document).ready(function () {
$("#message").inputNotes(
{
sexwarning: {
pattern: /(^|s)色情(s|$)/ig,
type: 'warning',
text: 'Do not type "sex"!'
},
numbersnote: {
pattern: /[0-9]/,
type: 'note',
text: 'Do not type numbers!'
}
}
);
});
为大家分享的代码如下
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>基于正则表达式的轻量提示插件</title>
<script src="js/jquery-1.7.1.js"></script>
<script src="js/jquery.inputnotes-0.6.js"></script>
</head>
<style>
div.inputnotes div.warning
{
color: #fff;
background: #f03;
}
</style>
<body>
若输入“不合法”字眼的文字将提示<br />
<textarea id="message" cols="60" rows="4" ></textarea>
<a href="javascript:void(null);" onclick="alert( $('#message').hasInputNotes() )"><br />文本框是否含不合法的字符</a>
<script>
$(document).ready(function () {
$("#message").inputNotes(
{
sexwarning: {
pattern: /(^|s)不合法(s|$)/ig,
type: 'warning',
text: '不能出现 "不合法"相关的字符!'
},
numbersnote: {
pattern: /[0-9]/,
type: 'note',
text: 'Do not type numbers!'
}
}
);
});
</script>
</body>
</html>
以上就是为大家分享的基于正则表达式的轻量提示插件,希望大家可以喜欢,并应用到实践中。
有用 | 无用
小提示:浏览器中如果不能正常运行,可以尝试切换浏览模式。 关键代码:
$(document).ready(function () {
$("#message").inputNotes(
{
sexwarning: {
pattern: /(^|s)色情(s|$)/ig,
type: 'warning',
text: 'Do not type "sex"!'
},
numbersnote: {
pattern: /[0-9]/,
type: 'note',
text: 'Do not type numbers!'
}
}
);
});
为大家分享的代码如下
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>基于正则表达式的轻量提示插件</title>
<script src="js/jquery-1.7.1.js"></script>
<script src="js/jquery.inputnotes-0.6.js"></script>
</head>
<style>
div.inputnotes div.warning
{
color: #fff;
background: #f03;
}
</style>
<body>
若输入“不合法”字眼的文字将提示<br />
<textarea id="message" cols="60" rows="4" ></textarea>
<a href="javascript:void(null);" onclick="alert( $('#message').hasInputNotes() )"><br />文本框是否含不合法的字符</a>
<script>
$(document).ready(function () {
$("#message").inputNotes(
{
sexwarning: {
pattern: /(^|s)不合法(s|$)/ig,
type: 'warning',
text: '不能出现 "不合法"相关的字符!'
},
numbersnote: {
pattern: /[0-9]/,
type: 'note',
text: 'Do not type numbers!'
}
}
);
});
</script>
</body>
</html>
以上就是为大家分享的基于正则表达式的轻量提示插件,希望大家可以喜欢,并应用到实践中。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- Bootstrap的图片轮播示例代码
- jQuery实现鼠标滑过点击事件音效试听
- js实现仿百度风云榜可重复多次调用的TAB切换选项卡效果
- js实现仿爱微网两级导航菜单效果代码
- jquery+CSS3模拟Path2.0动画菜单效果代码
- jQuery实现简单的列表式导航菜单效果代码
- jquery实现红色竖向多级向右展开的导航菜单效果
- jquery+CSS3实现淘宝移动网页菜单效果
- jQuery实现带有洗牌效果的动画分页实例
- jquery选择器简述
- 浅谈javascript的Array.prototype.slice.call
- jquery.mousewheel实现整屏翻屏效果
- 浅谈JavaScript超时调用和间歇调用
- javascript中substring()、substr()、slice()的区别
- javascript中sort() 方法使用详解
- javascript中的正则表达式使用详解
- jQuery鼠标事件汇总
- 简单谈谈javascript中的变量、作用域和内存问题
- jquery专业的导航菜单特效代码分享