Reputation: 227
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:
Corrects: spaces, letter, number, many words,-,+,_,/,.
Incorrects: ',",!,@,#,$,%,^,%,*,space in front and last
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):
Upvotes: 0
Views: 192
Reputation: 1896
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" />
Upvotes: 3