-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathrequired.js
More file actions
38 lines (34 loc) · 1000 Bytes
/
required.js
File metadata and controls
38 lines (34 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function check(form_button)
{
form = form_button.form;
var form_ok = true;
$(':input', form).each(function() {
form_id = $(form).attr('id');
if ($(this).hasClass('input-required') && $(this).val() == '') {
var type = this.type;
$(this).css('border-color', 'red');
switch (type) {
case 'text':
case 'textarea':
case 'file':
element_id = $(this).attr('id');
label_id = '#' + element_id + '-label';
label_value = $(label_id).html();
alert(check_message + label_value);
form_ok = false;
break;
default:
alert(type);
}
return false;
}
});
if (!form_ok) {
$(form).submit(function() {
return false;
});
} else {
form.submit();
return true;
}
}