亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

本文實例講述了基于正則表達式的輕量提示插件,分享給大家供大家參考。具體如下:
這是一款javascript實現(xià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>基于正則表達式的輕量提示插件</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) "不合法"相關的字符!'
         },
         numbersnote: {
           pattern: /[0-9]/,
           type: 'note',
           text: 'Do not type numbers!'
         }
       }
      );
    });

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

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

相關文章

最新評論