/*全角カタカナのみ*/
jQuery.validator.addMethod("katakana", function(value, element) {
	return this.optional(element) || /^([ァ-ヶー]+)$/.test(value);
	}, "全角カタカナを入力してください"
);
/*郵便番号（例:012-3456）*/
jQuery.validator.addMethod("postnum", function(value, element) {
	return this.optional(element) || /^\d{3}\-\d{4}$/.test(value);
	}, "郵便番号を入力してください（例:123-4567）"
);
/*郵便番号*/
jQuery.validator.addMethod("postnum2", function(value, element) {
	return this.optional(element) || /^([0-9|-]+)$/.test(value);
	}, "郵便番号を入力してください（例:123-4567）"
);

/*電話番号（例:012-345-6789）*/
jQuery.validator.addMethod("telnum", function(value, element) {
	return this.optional(element) || /^[0-9-]{12}$/.test(value);
	}, "電話番号を入力してください（例:012-345-6789）"
);

$(document).ready(function() {
    $("#InquiryAddForm").validate({
        rules : {
            'data[Inquiry][name]': {
                required: true,
                maxlength: 16
            },
            'data[Inquiry][name_kana]': {
                required: true,
                katakana: true,
                maxlength: 32
            },
            'data[Inquiry][tel]': {
                required: true,
                maxlength: 16
            },
            'data[Inquiry][mail]': {
                required: true,
                email: true,
                maxlength: 64
            },
            'data[Inquiry][age]': {
                required: true,
                number: true,
                maxlength: 4
            },
            'data[Inquiry][zip]': {
                required: true,
                postnum2: true,
                maxlength: 10
            },
            'data[Inquiry][prefecture]': {
                required: true,
                maxlength: 4
            },
            'data[Inquiry][city]': {
                required: true,
                maxlength: 16
            },
            'data[Inquiry][address]': {
                required: true,
                maxlength: 32
            },
            'data[Inquiry][accident_date]': {
                required: true,
                maxlength: 64
            },
            'data[Inquiry][accident_place]': {
                required: true,
                maxlength: 64
            },
            'data[Inquiry][insurance]': {
                required: true,
                maxlength: 16
            },
            'data[Inquiry][title]': {
                required: true,
                maxlength: 32
            },
            'data[Inquiry][content]': {
                required: true,
                maxlength: 2000
            },
            'law': {
                required: true
            }
        },
        messages: {
            'data[Inquiry][name]': {
                required: "氏名を入力して下さい"
            },
            'data[Inquiry][name_kana]': {
                required: "フリガナを入力して下さい",
                katakana: "カタカナで入力して下さい"
            },
            'data[Inquiry][tel]': {
                required: "お電話番号を入力して下さい"
            },
            'data[Inquiry][mail]': {
                required: "メールアドレスを入力して下さい",
                email: "アドレスの形式が正しくありません"
            },
            'data[Inquiry][age]': {
                required: "年齢を入力して下さい",
                number: "半角数字で入力して下さい"
            },
            'data[Inquiry][zip]': {
                required: "郵便番号を入力して下さい",
                postnum2: "半角数字で入力して下さい"
            },
            'data[Inquiry][prefecture]': {
                required: "都道府県を入力して下さい"
            },
            'data[Inquiry][city]': {
                required: "市区町村を入力して下さい"
            },
            'data[Inquiry][address]': {
                required: "番地、建物名などを入力して下さい"
            },
             'data[Inquiry][accident_date]': {
                required: "発生日時を入力して下さい"
            },
            'data[Inquiry][accident_place]': {
                required: "発生場所を入力して下さい"
            },
            'data[Inquiry][insurance]': {
                required: "加害者の保険会社を入力して下さい"
            },
            'data[Inquiry][title]': {
                required: "相談タイトルを入力して下さい"
            },
            'data[Inquiry][content]': {
                required: "事故の状況・相談内容を入力して下さい"
            },
             'law': {
                required: "規約に同意して下さい"
            }
      },
        errorClass: "error",
        errorElement: "em"
    });
});


$(document).ready(function() {
    $("#ClinetEditAddForm").validate({
        rules : {
            'data[Office][name]': {
                required: true,
                maxlength: 16
            },
            'data[Office][name_kana]': {
                required: true,
                katakana: true,
                maxlength: 32
            },
            'data[Office][zip]': {
                required: true,
                postnum2: true
            },
            'data[Office][city]': {
                required: true,
                maxlength: 16
            },
            'data[Office][address]': {
                required: true,
                maxlength: 32
            },
            'data[Office][station]': {
                required: true
            }
        },
        messages: {
            'data[Office][name]': {
                required: "氏名を入力して下さい"
            },
            'data[Office][name_kana]': {
                required: "フリガナを入力して下さい",
                katakana: "カタカナで入力して下さい"
            },
            'data[Office][zip]': {
                required: "郵便番号を入力して下さい",
                postnum2: "半角数字で入力して下さい"
            },
            'data[Office][city]': {
                required: "市区町村を入力して下さい"
            },
            'data[Office][address]': {
                required: "上記以下の住所を入力して下さい"
            },
            'data[Office][station]': {
                required: "最寄駅名を入力して下さい"
            }
      },
        errorClass: "error",
        errorElement: "em"
    });
});


$(document).ready(function() {
    $("#ClinetEditInfoAddForm").validate({
        rules : {
            'data[Information][president]': {
                required: true,
                maxlength: 16
            },
            'data[Information][birthday]': {
                required: true
            },
            'data[Information][belong]': {
                required: true
            },
            'data[Information][fee1]': {
                required: true,
                number: true
            },
            'data[Information][fee2]': {
                required: true,
                number: true
            },
            'data[Information][fee3]': {
                required: true,
                number: true
            }
        },
        messages: {
            'data[Information][president]': {
                required: "代表者氏名を入力して下さい"
            },
            'data[Information][birthday]': {
                required: "生年月日を入力して下さい"
            },
            'data[Information][belong]': {
                required: "所属団体を入力して下さい"
            },
            'data[Information][fee1]': {
                required: "相談料を入力して下さい",
                number: "半角数字で入力して下さい"
            },
            'data[Information][fee2]': {
                required: "着手金を入力して下さい",
                number: "半角数字で入力して下さい"
            },
            'data[Information][fee3]': {
                required: "報酬額を入力して下さい",
                number: "半角数字で入力して下さい"
            }
      },
        errorClass: "error",
        errorElement: "em"
    });
});

$(document).ready(function() {
    $("#ClientAddForm").validate({
        rules : {
            'data[ResponseOffice][content]': {
                required: true,
                maxlength: 1000
            }
        },
        messages: {
            'data[ResponseOffice][content]': {
                required: "内容を入力して下さい"
            }
      },
        errorClass: "error",
        errorElement: "em"
    });
});

$(document).ready(function() {
    $("#UserReplyAddForm").validate({
        rules : {
            'data[ResponseUser][content]': {
                required: true,
                maxlength: 1000
            }
        },
        messages: {
            'data[ResponseUser][content]': {
                required: "内容を入力して下さい"
            }
      },
        errorClass: "error",
        errorElement: "em"
    });
});

$(document).ready(function() {
    $("#ContactAddForm").validate({
        rules : {
            'data[Contact][company]': {
                required: true,
                maxlength: 32
            },
            'data[Contact][name]': {
                required: true,
                maxlength: 32
            },
            'data[Contact][tel]': {
                required: true,
                maxlength: 16
            },
            'data[Contact][mail]': {
                required: true,
                email: true,
                maxlength: 64
            },
            'data[Contact][content]': {
                required: true,
                maxlength: 2000
            },
            'contact': {
                required: true
            }
        },
        messages: {
            'data[Contact][company]': {
                required: "御社名・事務所名を入力して下さい"
            },
            'data[Contact][name]': {
                required: "担当者氏名を入力して下さい"
            },
            'data[Contact][tel]': {
                required: "お電話番号を入力して下さい"
            },
            'data[Contact][mail]': {
                required: "メールアドレスを入力して下さい",
                email: "アドレスの形式が正しくありません"
            },
            'data[Contact][content]': {
                required: "内容を入力して下さい"
            },
            'contact': {
                required: "規約に同意して下さい"
            }
      },
        errorClass: "error",
        errorElement: "em"
    });
});

$(document).ready(function() {
    $("#UserReplyAddForm").validate({
        rules : {
            'data[ResponseUser][content]': {
                required: true,
                maxlength: 1000
            }
        },
        messages: {
            'data[ResponseUser][content]': {
                required: "内容を入力して下さい"
            }
      },
        errorClass: "error",
        errorElement: "em"
    });
});


$(document).ready(function() {
    $("#QuestionAddForm").validate({
        rules : {
            'data[Question][name]': {
                required: true,
                maxlength: 32
            },
            'data[Question][mail]': {
                required: true,
                email: true,
                maxlength: 64
            },
            'data[Question][age]': {
                required: true,
                number: true,
                maxlength: 3
            },
            'data[Question][title]': {
                required: true,
                maxlength: 64
            },
            'data[Question][content]': {
                required: true,
                maxlength: 2000
            },
            'data[Question][tag][]': {
                maxlength: 5
            },
            'law': {
                required: true
            }
        },
        messages: {
            'data[Question][name]': {
                required: "ニックネームを入力して下さい"
            },
            'data[Question][mail]': {
                required: "メールアドレスを入力して下さい",
                email: "アドレスの形式が正しくありません"
            },
            'data[Question][age]': {
                required: "年齢を入力して下さい",
                number: "半角数字で入力して下さい"
            },
            'data[Question][title]': {
                required: "質問タイトルを入力して下さい"
            },
            'data[Question][content]': {
                required: "質問の内容を入力して下さい"
            },
            'data[Question][tag][]': {
                maxlength: "選択できるのは5つまでです"
            },
            'law': {
                required: "規約に同意して下さい"
            }
      },
        errorClass: "error",
        errorElement: "em"
    });
});

$(document).ready(function() {
    $("#AdminEditAreaAddForm").validate({
        rules : {
            'data[Area][prefecture_id][]': {
                required: true
            }
        },
        messages: {
            'data[Area][prefecture_id][]': {
                required: "必ず一つはチェックして下さい。"
            }
      },
        errorClass: "error",
        errorElement: "em"
    });
});

