欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js實(shí)現(xiàn)基于正則表達(dá)式的輕量提示插件

 更新時(shí)間:2015年08月29日 15:52:48   投稿:lijiao  
這篇文章主要介紹了基于正則表達(dá)式的輕量提示插件,兼容性強(qiáng)卻文件輕巧的文本框檢測(cè)插件,推薦給大家,有需要的小伙伴可以參考下。

本文實(shí)例講述了基于正則表達(dá)式的輕量提示插件,分享給大家供大家參考。具體如下:
這是一款javascript實(shí)現(xiàn)基于正則表達(dá)式的輕量提示插件,本插件是基于正則表達(dá)式進(jìn)行文本框檢測(cè)的,通用性十分強(qiáng),大家可以在實(shí)例中進(jìn)行使用。
運(yùn)行效果圖:               -------------------查看效果-------------------

小提示:瀏覽器中如果不能正常運(yùn)行,可以嘗試切換瀏覽模式。
關(guān)鍵代碼:

    $(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>基于正則表達(dá)式的輕量提示插件</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: '不能出現(xiàn) "不合法"相關(guān)的字符!'
         },
         numbersnote: {
           pattern: /[0-9]/,
           type: 'note',
           text: 'Do not type numbers!'
         }
       }
      );
    });

  </script>
</body>
</html>

以上就是為大家分享的基于正則表達(dá)式的輕量提示插件,希望大家可以喜歡,并應(yīng)用到實(shí)踐中。

相關(guān)文章

最新評(píng)論