10 examples of 'textarea validation in jquery' in JavaScript

Every line of 'textarea validation in jquery' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
83function validate(container) {
84 var result = true,
85 _required = _validateRequired(container),
86 _widget = textArea.getWidget(true),
87 invalid,
88 candidates = (Widget.isOneOfMe(container, _widget) ? [container] : Widget.findDescendants(container, _widget));
89
90 if (candidates && candidates.length && (invalid = Array.prototype.filter.call(candidates, doContraintValidityTest))) {
91 result = (invalid.length === 0);
92 }
93 return result && _required;
94}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

5function checkTheTextarea(){
6 var textAreaText = false;
7 //Check textarea
8 var textArea = document.getElementById("contents"); //Get the text area
9 if(textArea) textAreaText = theTextareaIsNotEmpty(textArea.value);
10 //END Check textarea
11 //Check iFrame
12 var iFrame = document.getElementById("frame_contents");
13 if(iFrame&&iFrame.style.display=="inline"){
14 var innerDoc = iFrame.contentDocuments || iFrame.contentWindow.document;
15 if(innerDoc){
16 var frameTextArea = innerDoc.getElementById("selection_field");
17 textAreaText = theTextareaIsNotEmpty(frameTextArea.textContent||frameTextArea.innerText);
18 }
19 }
20 //END Check iFrame
21 //Toggle Submit button status
22 var formSubmitButton = document.getElementById("autoinstallationDetailsUpdateButton");
23 if(formSubmitButton){
24 if(textAreaText && formSubmitButton.disabled) formSubmitButton.disabled = false;
25 if(!textAreaText && !formSubmitButton.disabled) formSubmitButton.disabled = true;
26 }
27 checkTheTextareaTimer = setTimeout(function(){checkTheTextarea()}, 1200);
28}
87function check_validation(element_id)
88{
89 if(!($(element_id).val()))
90 {
91 $(element_id).parent().parent().parent().addClass("errors");
92 $(element_id).parent().parent().parent().children('ul').show();
93 $("#errornote").show();
94 return true;
95 }
96 else
97 return false;
98}
64function validate(input) {
65 let valid = validatePresence(input);
66
67 // TODO change this to using classList
68 $(input).removeClass('error');
69
70 if (!valid) {
71 $(input).addClass('error');
72 return false;
73 }
74
75 if ($(input).data('validation-type') === 'monetary') {
76 valid = validateMonetaryValue(input);
77 }
78
79 if (!valid) {
80 $(input).addClass('error');
81 return false;
82 }
83
84 return true;
85}
86function validate(form) {
87 if(jQuery("#access_id").val() == '') {
88 jQuery("#access_id").parent().parent().addClass('has-warning');
89 return false;
90 } else if(jQuery("#access_key").val() == '') {
91 jQuery("#access_key").parent().parent().addClass('has-warning');
92 return false;
93 } else if(jQuery("#bucket").val() == '') {
94 jQuery("#bucket").parent().parent().addClass('has-warning');
95 return false;
96 } else if(jQuery("#hostname").val() == '') {
97 jQuery("#hostname").parent().parent().addClass('has-warning');
98 return false;
99 }
100 return true;
101}
85function validate(form) {
86 var i = 0;
87 jQuery("input.required").each(function() {
88 if(jQuery(this).val() == '') {
89 jQuery(this).focus();
90 return false;
91 }
92 i++;
93 });
94 if(i < jQuery("input.required").length) {
95 return false;
96 } else {
97 return true;
98 }
99}
100function validate() {
101 var $this = $(this);
102 var $parentElem = $this.closest(".brz-form__item");
103 var value = $this.val();
104 var data = $this.data();
105 var type = data.type;
106 var result = true;
107 var isRequired = $this.prop("required");
108 var pattern = $this.attr("pattern");
109
110 $parentElem.removeClass(
111 "brz-form__item--error brz-form__item--error-pattern brz-form__item--error-required"
112 );
113
114 if (type === "Number") {
115 if (isRequired && !new RegExp(pattern).test(value)) {
116 $parentElem.addClass(
117 "brz-form__item--error brz-form__item--error-pattern"
118 );
119 result = false;
120 }
121 } else if (!new RegExp(pattern).test(value)) {
122 $parentElem.addClass(
123 "brz-form__item--error brz-form__item--error-pattern"
124 );
125 result = false;
126 }
127
128 if (isRequired && !value.length) {
129 $parentElem.addClass(
130 "brz-form__item--error brz-form__item--error-required"
131 );
132 result = false;
133 }
134
135 return result;
136}
32function validateForm() {
33 var user = document.forms["myForm"]["user"].value;
34
35 if(user.trim() == "") {
36 document.getElementById("userError").innerHTML = "Remplir le champ svp !";
37 return false;
38 }
39 return true;
40}
1function validateForm(element) {
2 var result = true;
3 element.find('[required]').each(
4 function () {
5 var fieldElement = $(this);
6 //如果为null则设置为''
7 var value = editor.getValue() || '';
8 if (value) {
9 value = value.trim();
10 }
11 if (!value || value === fieldElement.attr('data-placeholder')) {
12 alert((fieldElement.attr('data-name') || this.name) + "不能为空!");
13 result = false;
14 return result;
15 }
16 }
17 );
18 return result;
19}
8function validateForm(f)
9{
10 if ((!f.scm_integration[0].checked) && (!f.scm_integration[1].checked)) {
11 alert('{/literal}{t escape=js}Please choose whether the SCM integration feature should be enabled or not.{/t}{literal}');
12 return false;
13 }
14 if (f.scm_integration[0].checked) {
15 field = getFormElement(f, 'checkout_url');
16 if (isWhitespace(field.value)) {
17 alert('{/literal}{t escape=js}Please enter the checkout page URL for your SCM integration tool.{/t}{literal}');
18 selectField(f, 'checkout_url');
19 return false;
20 }
21 field = getFormElement(f, 'diff_url');
22 if (isWhitespace(field.value)) {
23 alert('{/literal}{t escape=js}Please enter the diff page URL for your SCM integration tool.{/t}{literal}');
24 selectField(f, 'diff_url');
25 return false;
26 }
27 field = getFormElement(f, 'scm_log_url');
28 if (isWhitespace(field.value)) {
29 alert('{/literal}{t escape=js}Please enter the log page URL for your SCM integration tool.{/t}{literal}');
30 selectField(f, 'scm_log_url');
31 return false;
32 }
33 }
34 return true;
35}

Related snippets