求人応募フォーム - アルテマ

'); } else { } }); ajax_result.fail(function(result) { var add_class = "failed"; var msg = messages['mail-sent-ng']; $("#form-area").html('

'+msg+'

'); }); return e.preventDefault(); } function is_valid() { var msg = {}; if ($("[name=formdummytextarea]").val()) { msg['formdummytextarea'] = true; } else { // 初期化 $.each($('#form-50 :input'), function(i, fields){ msg[$(fields).attr('name')] = ''; }); msg = is_valid_validity(msg); msg = is_valid_other(msg); } return set_error_msg(msg); } // html5 validity function is_valid_validity() { var f = document.forms['form-50']; var items = f.elements; var len = items.length; var msg = {}; $(".validation-errors").text(""); $(".validation-errors").css('display', 'none'); for (var i = 0; i $(fields).attr('maxlength')) msg[name] = messages['maxlength-over']; } else if ($(fields).attr('type') == 'email') { if (!validateEmail(val)) msg[name] = messages['invalid-email']; } else if ($(fields).attr('type') == 'url') { if (!validateUrl(val)) msg[name] = messages['invalid-url']; } else if ($(fields).attr('type') == 'tel') { } else if ($(fields).attr('type') == 'date') { if (!validateDate(val)) msg[name] = messages['invalid-date']; } else if ($(fields).attr('type') == 'number' || $(fields).attr('type') == 'range') { if ($(fields).attr('min') && Number(val) $(fields).attr('max')) { if ($(fields).attr('type') == 'date') { msg[name] = messages['date-too-late']; } else { msg[name] = messages['number-too-large']; } } } } else { } } }); return msg; } function validateEmail(email) { var re = /^(([^()\[\]\\.,;:\[email protected]"]+(\.[^()\[\]\\.,;:\[email protected]"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } function validateUrl(url) { var re = /(http(s)?:\/\/.)?(www\.)?[[email protected]:%._\+~#=]{2,256}\.[a-z]{2,6}\b([[email protected]:%_\+.~#?&//=]*)/g; return re.test(url); } function validateDate(in_date) { var arr = []; if (in_date.length == 8 && in_date.match(/\d{8}/)) { arr[0] = in_date.substr(0, 4); arr[1] = in_date.substr(4, 2); arr[2] = in_date.substr(6, 2); } else { arr = in_date.split(/-|\//); } console.log(arr); dt = new Date(arr[0], arr[1]-1, arr[2]); return (dt.getFullYear()==arr[0] && dt.getMonth()==arr[1]-1 && dt.getDate()==arr[2]); } function set_error_msg(msg) { var i = 0; for (name in msg) { if (msg[name]) i++; if (name == 'formdummytextarea') break; var cntl = '#form-control-' + name.replace('[]', ''); console.log(cntl); var p = $(cntl).parent(); console.log(".item-error-"+name); var error_class = "item-error-" + name.replace('[]', ''); if ($("."+error_class).length) { $("."+error_class).text(msg[name]); } else if (msg[name] != '') { $(p).append('' + msg[name] + ''); } } if (i) { if (msg['formdummytextarea']) { $(".validation-errors").text(messages['spam']); } else { $(".validation-errors").text(messages['validation-error']); } $(".validation-errors").css('display', 'block'); return false; } else { $(".validation-errors").text(""); $(".validation-errors").css('display', 'none'); return true; } } function api_exec(data) { return $.ajax({ type: 'POST', url: '/api/form_api', dataType: 'text', data: data, success: function(result) { result = JSON.parse(result); if (result.error) { if (result.msg) { //alert(result.msg); } else { //alert('エラーが発生しました。もうしばらくしてから・・'); } return false; } return result; }, error: function(result) { console.log(result); //alert("エラーが発生しました"); } }); } function quiz_gametitle(){ return false; } //--> image

You May Like Also

  • ゲーム攻略ライター募集