- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
function Order(obj) {
var frm = $(obj);
var first_name = frm.find("input[name='first_name']").val();
var last_name = frm.find("input[name='last_name']").val();
var email = frm.find("input[name='email']").val();
var phone = frm.find("input[name='phone']").val();
var text = frm.find(".coment-form-textarea").val();
var captcha = frm.find("input[name='captcha']").val();
var valid = true;
MsgErrorDestroy(frm, '#order-first_name', 'input[name="first_name"]');
MsgErrorDestroy(frm, '#order-last_name', 'input[name="last_name"]');
MsgErrorDestroy(frm, '#order-email', 'input[name="email"]');
MsgErrorDestroy(frm, '#order-phone', 'input[name="phone"]');
MsgErrorDestroy(frm, '#order-text', '.coment-form-textarea');
if (first_name == '') {
MsgError(frm, 'Введите ваше имя.', '#order-first_name', 'input[name="first_name"]');
valid = false;
}
if (last_name == '') {
MsgError(frm, 'Введите вашу фамилию.', '#order-last_name', 'input[name="last_name"]');
valid = false;
}
if (!emailValid(email)) {
MsgError(frm, 'Введите ваш email.', '#order-email', 'input[name="email"]');
valid = false;
}
if (phone == '') {
MsgError(frm, 'Введите ваш номер телефона.', '#order-phone', 'input[name="phone"]');
valid = false;
}
if (text == '') {
MsgError(frm, 'Введите ваше сообщение.', '#order-text', '.coment-form-textarea');
valid = false;
}
if (captcha == '') {
MsgError(frm, 'Введите капчу.', '#comment-capcha', 'input[name="captcha"]');
valid = false;
}
if (valid == false) {
return false;
}
}
function MsgError(frm, msg, select_msg, select_input) {
if (select_msg != 0) {frm.find(select_msg).html(msg);}
if (select_input != 0) {frm.find(select_input).addClass('input-error');}
if (select_msg != 0) {frm.find(select_msg).removeClass('hide');}
//frm.find('#'+'profile-'+key).addClass('show');
}
function MsgErrorDestroy(frm, select_msg, select_input) {
if (select_msg != 0) {frm.find(select_msg).html('');}
if (select_input != 0) {frm.find(select_input).removeClass('input-error');}
if (select_msg != 0) {frm.find(select_msg).removeClass('show');}
//$('#'+'profile-'+key).addClass('hide');
}
Валидация какого-то там заказа. Автор вероятно не слышал про массивы и объекты.