将用户输入 指定 文本字符串进行比较 jFieldCompareString

  • 源码大小:55.92KB
  • 所需积分:1积分
  • 源码编号:19JP-3485
  • 浏览次数:649次
  • 最后更新:2023年06月18日
  • 所属栏目:文本
本站默认解压密码:19jp.com 或 19jp_com

简介

jFieldCompareString是一个小型快速的jQuery插件,用于检测输入或文本区域的值是否与您指定的文本字符串匹配。

特征:

  • 自定义反馈(错误/不完整/成功)消息。
  • 允许您防止复制粘贴和拖放。

如何使用它:

1.在文档中加载jQuery jFieldCompareString插件的文件。

  1. <link rel="stylesheet" href="dist/css/jquery.jFieldCompareString.css" />
  2. <script src="/path/to/cdn/jquery.min.js"></script>
  3. <script src="dist/js/jquery.jFieldCompareString.js"></script>

2.将参考文本添加到jfcs参考容器

  1. <div class="jfcs-wrapper">
  2. <div class="jfcs-reference">
  3. I Love jQueryScript.Net
  4. </div>
  5. </div>

3.在jfcs参考容器

  1. <div class="jfcs-wrapper">
  2. <div class="jfcs-reference">
  3. I Love jQueryScript.Net
  4. </div>
  5. <div class="jfcs-field">
  6. <input type="text" id="example" />
  7. </div>
  8. </div>

4.在文本字段上初始化插件并完成。

  1. $(function() {
  2. $('#example').jFieldCompareString();
  3. });

5.确定是否防止复制粘贴和拖放。默认值:false。

  1. $(function() {
  2. $('#example').jFieldCompareString({
  3. field_protection: true,
  4. });
  5. });

6.自定义反馈信息。

  1. $(function() {
  2. $('#example').jFieldCompareString({
  3. msg_notok: 'Your transcript has an error, please correct.',
  4. msg_incomplete: 'Your transcript is incomplete, please correct.',
  5. msg_ok: 'Your transcript is correct.'
  6. });
  7. });

预览截图