我找不到最简单的textarea验证 [英] I can't find the simplest of textarea validation

查看:70
本文介绍了我找不到最简单的textarea验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想用jQuery中的onkeypress带有验证规则的最简单的textarea,而不是HTML5,bootstrap或angularJS中的验证规则.我在任何地方都找不到.例如,它由以下填充:

I want just a simplest textarea with validation rule by onkeypress in jQuery but NOT in HTML5, bootstrap, or angularJS. I can't find it anywhere. For example it fills by these:

更正:spaces, letter, number, many words,-,+,_,/,.

不正确:',",!,@,#,$,%,^,%,*,space in front and last

我可以通过angularJS做到这一点,但不能在JQuery中做到.我只想要jQuery模式或jQuery中的另一种方式.如果文本区域的内容格式不正确,则隐藏或禁用提交按钮.感谢您的帮助.

I can do it by angularJS but not in JQuery. I just want it in jQuery pattern or another way in jQuery. If the content of textarea is not in the correct way in its pattern, the submit button hiding or disabled then. Thanks for your help.

我一直在寻找像这样的引用(它们可以用'单引号填充):

I've been looking for references among them like these (they can be filled by ' single quote):

  1. http://www.jeasyui.com/tutorial/form/form3.php
  2. http://trevordavis.net/play/jQuery-Simple-Validate/
  3. http://www.innovativephp.com/applications/demos/jquery_form_validation_examples/textarea_validation
  4. http://jsfiddle.net/ZAaPu/
  5. https://www.daniweb. com/programming/web-development/threads/449610/textarea-validation-problem-jquery
  1. http://www.jeasyui.com/tutorial/form/form3.php
  2. http://trevordavis.net/play/jQuery-Simple-Validate/
  3. http://www.innovativephp.com/applications/demos/jquery_form_validation_examples/textarea_validation
  4. http://jsfiddle.net/ZAaPu/
  5. https://www.daniweb.com/programming/web-development/threads/449610/textarea-validation-problem-jquery

推荐答案

您可以随时尝试以下方法:

You can always try this:

$(document).ready(function() {
    $('#input').keyup(function() {
	    if(!$(this).val().match(/^(?!\s)([a-zA-Z0-9 _.)?&]){1,}$/g)) {
           $('#button').prop('disabled', true);
        }else{
           $('#button').prop('disabled', false);
        }
    });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input id="input" />
<input id="button" type="button" value="submit" />

这篇关于我找不到最简单的textarea验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆