-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
43 lines (42 loc) · 1.37 KB
/
main.js
File metadata and controls
43 lines (42 loc) · 1.37 KB
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
39
40
41
42
43
/*CONTACT FUNTION*/
(function($) {
"use strict";
var name = $('.validate-input input[name="name"]');
var email = $('.validate-input input[name="email"]');
var subject = $('.validate-input input[name="subject"]');
var message = $('.validate-input textarea[name="message"]');
$('.validate-form').on('submit', function() {
var check = true;
if ($(name).val().trim() == '') {
showValidate(name);
check = false;
}
if ($(subject).val().trim() == '') {
showValidate(subject);
check = false;
}
if ($(email).val().trim().match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{1,5}|[0-9]{1,3})(\]?)$/) == null) {
showValidate(email);
check = false;
}
if ($(message).val().trim() == '') {
showValidate(message);
check = false;
}
return check;
});
$('.validate-form .input1').each(function() {
$(this).focus(function() {
hideValidate(this);
});
});
function showValidate(input) {
var thisAlert = $(input).parent();
$(thisAlert).addClass('alert-validate');
}
function hideValidate(input) {
var thisAlert = $(input).parent();
$(thisAlert).removeClass('alert-validate');
}
}
)(jQuery);