$('#stwform').validate({ rules: { intention_text: { intention_other: true }, area_text: { area_other: true }, hotel_text: { hotel_other: true }, departure_text: { departure_other: true }, mileage_text: { mileage_other: true }, budget_text: { budget_other: true }, person_text1: { person_num: true }, experience_text: { experience_other: true }, departure: { required: true }, airline_text1: { airline_request: true }, airline_text2: { airline_other: true }, name: { required: true }, kana: { required: true, katakana: true }, email: { required: true, email: true }, tel: { required: true, number: true }, 'postal-code': { required: false, number: true }, 'address-level1': { required: false }, 'address-level2': { required: false }, agree: { required:true } }, messages: { intention_text: { intention_other: 'その他をご入力下さい' }, departure: { required: 'ご希望出発地を選択してください' }, name: { required: 'お名前を入力してください' }, kana: { required: 'フリガナを入力してください' }, email: { required: 'メールアドレスを入力してください' }, tel: { required: '電話番号を入力してください' }, 'postal-code': { required: '郵便番号を入力してください' }, 'address-level1': { required: '住所を入力してください' }, 'address-level2': { required: '住所を入力してください' }, agree: { required: '個人情報の取扱への同意が必要です' } }, groups: { birth: "birth1 birth2 birth3", pack_day: "pack_day1 pack_day2 pack_day3", check_in_day: "check_in_day1 check_in_day2" }, errorPlacement: function (error, element) { error.insertAfter(element); // ここが呼び出される if (element.attr("name") == "departure") error.insertAfter("#departure_err"); if (element.attr("name") == "area_text") error.insertAfter("#area_err"); if (element.attr("name") == "hotel_text") error.insertAfter("#hotel_err"); if (element.attr("name") == "budget_text") error.insertAfter("#budget_err"); if (element.attr("name") == "person_text1") error.insertAfter("#person_err"); if (element.attr("name") == "agree") error.insertAfter("#agree_err"); }, submitHandler: function(form) { if ( $('#btn1').val() == '上記の内容で送信する' ){ $('#stwform').find(':input:not([type=button]):not([type=submit])').attr('disabled', false); $('#stwform').attr('action','?act=send'); form.submit(); }else{ $('#stwform').find(':input:not([type=button]):not([type=submit])').attr('disabled', true); $('#btn1').val('上記の内容で送信する'); $('.form_wrap-privacypolicy').hide(); console.log('ok'); $('#btn2').css('display','block'); } }, focusInvalid:"true" }); jQuery.validator.addMethod("airline_request", function(value, element) { var airline_request_flg = true; $('[id^=checkbox-airline]:checked').map(function(){ if ( $(this).val() == "希望がある" && !value ){ airline_request_flg = false; } }); return airline_request_flg; },'ご希望内容をご入力下さい' ); jQuery.validator.addMethod("mileage_other", function(value, element) { if ( $('[id^=radio-mileage]:checked').val() == "その他" && !value ){ return false; }else{ return true; } },'その他をご入力下さい' ); jQuery.validator.addMethod("airline_other", function(value, element) { var airline_other_flg = true; $('[id^=checkbox-airline]:checked').map(function(){ if ( $(this).val() == "その他" && !value ){ airline_other_flg = false; } }); return airline_other_flg; },'その他をご入力下さい' ); jQuery.validator.addMethod("experience_other", function(value, element) { if ( $('[id^=radio-experience]:checked').length > 0 && $('[id^=radio-experience]:checked').val().match(/^あり/) && !value ){ return false; }else{ return true; } },'クルーズ旅行経験をご入力下さい' ); jQuery.validator.addMethod("person_num", function(value, element) { if ( $('[id^=radio-person]:checked').val() == "決まっている" && !value ){ return false; }else{ return true; } },'ご旅行人数をご入力下さい' ); jQuery.validator.addMethod("budget_other", function(value, element) { if ( $('[id^=radio-budget]:checked').val() == "決まっている" && !value ){ return false; }else{ return true; } },'ご予算をご入力下さい' ); jQuery.validator.addMethod("departure_other", function(value, element) { if ( $('[id^=radio-departure]:checked').val() == "その他" && !value ){ return false; }else{ return true; } },'その他ご入力下さい' ); jQuery.validator.addMethod("intention_other", function(value, element) { var intention_other_flg = true; $('[id^=checkbox-intention]:checked').map(function(){ if ( $(this).val() == "その他" && !value ){ intention_other_flg = false; } }); return intention_other_flg; },'その他ご入力下さい' ); jQuery.validator.addMethod("hotel_other", function(value, element) { if ( $('[id^=radio-hotel]:checked').val() == "希望がある" && !value ){ return false; }else{ return true; } },'ホテルをご入力下さい' ); jQuery.validator.addMethod("area_other", function(value, element) { if ( $('[id^=radio-area]:checked').val() == "決まっている" && !value ){ return false; }else{ return true; } },'方面をご入力下さい' ); jQuery.validator.addMethod("katakana", function(value, element) { return this.optional(element) || /^[ア-ン゛゜ァ-ォャ-ョー「」、  ]+$/.test(value); }, "全角カタカナを入力してください" ); $('#btn2').click(function () { $('.form_wrap-privacypolicy').show(); $('#stwform').find(':input:not([type=button]):not([type=submit])').attr('disabled', false); $('#btn1').val('確認する'); $(this).hide(); });