0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PowerApps ポータル画面入力チェックカスタマイズ追加

Last updated at Posted at 2023-03-02
//必須項目チェックを追加する
function RequiredCheckAdd(id, name) {
    if (typeof (Page_Validators) == 'undefined') {
        Page_Validators = [];
    }
    // Create new validator
    var newValidator = document.createElement('span');
    newValidator.style.display = "none";
    newValidator.id = id + "Validator";
    newValidator.controltovalidate = id;
    newValidator.errormessage = "<a href='#" + id + "_label'>" + name + " は必須フィールドです。</a>";
    newValidator.validationGroup = "";
    newValidator.initialvalue = "";
    newValidator.evaluationfunction = function () { };
    // Add the new validator to the page validators array:
    Page_Validators.push(newValidator);
    $("a[href='#" + id + "_label']").on("click", function () {
        scrollToAndFocus(id + '_label', id);
    });
}
//上記のチェックを追加する前に直前チェックしたころより、残りメッセージをクリアするため、以下のメソッドでクリアする
function CheckRequired(flg) {
    //前回チェックメッセージが残された場合、クリア
    if (typeof (Page_Validators) !== 'undefined') {
        for (let i = 0; i < 2; i++) {
            for (let i = 0; i < Page_Validators.length; i++) {
                var element = Page_Validators[i].outerHTML;
                if (element.includes("new_field1Validator") || element.includes("new_field2Validator")) {
                    Page_Validators.splice(i, 1);
                }
            }
        }
    }

    if (flg == 1) {
        //field1が空白の場合
        if ($("#new_field1").val() === "") {
            RequiredCheckAdd("new_field1", "フィールド1");
        }
        //field2が空白の場合
        if ($("#field2").val() === "") {
            RequiredCheckAdd("new_field2", "フィールド2");
        }
    } else if (flg == 2) {
        //field3が空白の場合
        if ($("#new_field3").val() === "") {
            RequiredCheckAdd("new_field3", "フィールド3");
        }
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?