10 examples of 'how to check textbox is empty in jquery' in JavaScript

Every line of 'how to check textbox is empty 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
28function isEmpty(form, a_values, a_checks)
29{
30 feed_back = "";
31
32 if (a_values != "")
33 {
34 if (a_values == "all")
35 {
36 for(var i=0;i<form.length;i++)
37 {
38 if (form.elements[i].type == "text" || form.elements[i].type == "textarea")
39 {
40 if (form.elements[i].value == "")
41 feed_back += "-> " + form.elements[i].id + "\n";
42 }
43 }
44 }
45 }
46
47 if (feed_back != "") {
48 alert("Please insert these data:\n\n" + feed_back);
49 return false;
50 }
51
52 return true;
53}
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

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}
20function isEmptyField(id) {
21 var elementId = document.getElementById(id);
22 if (elementId != null && elementId != undefined) {
23 if (elementId.value == "" || elementId.value == null || elementId.value == undefined) {
24 return true;
25 }
26 }
27 return false;
28}
16function check_input()
17 {
18 var number_regex=/[0-9]{5,}/;
19
20 if(!number_regex.test(launch_instance.vnode_memsize.value))
21 {
22 alert("Memory must be number and it should be greater than 10000Kb");
23 launch_instance.vnode_memsize.focus();
24 return false;
25 }
26 }
60isEmpty(value) {
61 let empty = true;
62 for (const key in value) {
63 if (value.hasOwnProperty(key) && value[key]) {
64 empty = false;
65 break;
66 }
67 }
68
69 return empty;
70}
176function checkUserInput() {
177 // this is crude. should add relavent errors
178 if ($('#storage_modules').val() != null){
179 if ($('#redstone_modules').val() != null) {
180 if ($('#module_side').val() != null) {
181 if ($('#output_value').val() != null) {
182 if ($('#trigger_value').val() != null) {
183 return true;
184 }
185 }
186 }
187 }
188 }
189 return false;
190}
14function check_form(){
15 clear_msg();
16 var username = $('username').value,
17 password = $('password').value,
18 password2 = $('password2').value,
19 email = $('email').value;
20 if(!/^[a-zA-Z]/.test(username)){
21 set_msg("请输入用户名,并以字母开头");
22 return false;
23 }
24
25 if(!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(email)){
26 set_msg("邮箱为空或格式不正确");
27 return false;
28 }
29 if(password.length == 0){
30 set_msg("请输入密码");
31 return false;
32 }
33 if(password!=password2){
34 set_msg("两次密码不一致,请修改");
35 return false;
36 }
37
38
39
40
41 return true;//防止表单提交,如果后台有接口改为return true; 就可以提交表单了
42}
71function check_content(){
72if($("#post_content").val().length < 4){
73alert("对不起,回复内容不能少于4个字符!")
74$("#post_content").focus();
75return false;
76} else{
77 return true;
78}
79}
5function check(){
6 var blocklabel = document.getElementById('blocklabel');
7 var val = trim(blocklabel.value);
8 if(val == "") {
9 alert(alert_arr.BLOCK_NAME_CANNOT_BE_BLANK);
10 return false;
11 }
12 return true;
13}
8function checkInputElement(elementId) {
9 var element = document.getElementById(elementId);
10 return element == null || (element.value || '') !== '';
11}

Related snippets