/** * 団体情報(パスワード変更)フォーム */ class WpGroupInfoPasswdEditJsForm { /** * コンストラクタ */ constructor() { /** ユーザID */ this.group_id = ""; /** メールアドレス */ this.mail_address = ""; /** パスワード */ this.password = ""; /** パスワード(確認用) */ this.password_confirm = ""; // コントロールクリア this.setControlStyle("password", "border: 1px solid #ccc;"); this.setControlStyle("password_confirm", "border: 1px solid #ccc;"); } /** * フォームデータを設定 */ setFormData() { var elm_password = document.getElementById('vol_form').password; if (elm_password != null) { this.password = elm_password.value; } var elm_password_confirm = document.getElementById('vol_form').password_confirm; if (elm_password_confirm != null) { this.password_confirm = elm_password_confirm.value; } } /** * バリデーション */ validate() { let errInfo = []; // 必須チェック if (this.password == "") { errInfo.push(["password", "パスワードを入力してください。"]); } if (this.password_confirm == "") { errInfo.push(["password_confirm", "パスワード(確認用)を入力してください。"]); } // 桁数チェック if (errInfo.length == 0) { if (this.group_id.length > 32) { errInfo.push(["group_id", "ユーザIDの文字数が大きすぎます。"]); } if (this.mail_address.length > 256) { errInfo.push(["mail_address", "メールアドレスの文字数が大きすぎます。"]); } if (this.password.length > 32) { errInfo.push(["password", "パスワードの文字数が大きすぎます。"]); } if (this.password_confirm.length > 32) { errInfo.push(["password_confirm", "パスワード(確認用)の文字数が大きすぎます。"]); } } // 入力形式チェック if (errInfo.length == 0) { if (validPasswd(this.password) != true) { errInfo.push(["password", "パスワードの入力形式が正しくありません。"]); } if (validPasswd(this.password_confirm) != true) { errInfo.push(["password_confirm", "パスワード(確認用)の入力形式が正しくありません。"]); } } // 範囲チェック if (errInfo.length == 0) { } // 相関チェック if (errInfo.length == 0) { var errMsg = eqPasswd(this.password, this.password_confirm); if (errMsg != "") { errInfo.push(["password", errMsg]); } } // エラー情報設定 errInfo.forEach(function(err) { this.setControlStyle(err[0], "border: 1px solid red;"); }, this); return errInfo; } /** * コントロールにスタイルを適用する */ setControlStyle(ctrlName, style) { let ctrls = document.getElementsByName(ctrlName); ctrls.forEach(function(ctrl) { ctrl.style = style; }); } }