spjs.dffs.alert Required Inputs

Forums Dynamic Forms for SharePoint spjs.dffs.alert Required Inputs

Viewing 1 reply thread
  • Author
    Posts
    • #26031
      becca
      Participant

      Sorry if there’s a post on this already, stuck working off my phone again so it’s harder to do good searches.

      I set up an alert with a textarea and a number input that will save or return false for the ok and cancel buttons, but I need to make it so you can only save if both inputs have a non-blank value. Is it possible to do this OR put fields in the alert dialog? (both inputs need values so I can enter them into fields)

    • #26043
      Alexander Bautz
      Keymaster

      You cannot use the default OK button because it will close the dialog, but you can hide the OK button and insert your own custom button like this:

      spjs.dffs.alert({
          "title": "Test required fields",
          "msg": "Textarea:<br><textarea id='myTextarea' style='width:100%;height:75px;box-sizing:border-box;' onkeyup></textarea><br>Number:<br><input type='number' id='myNumber' style='width:100%;box-sizing:border-box;'><div style='color:red;display:none;' id='myFormValidation'>Please fill in both fields!</div><div style='text-align:right;padding-top:15px;'><input type='button' class='spjs-dlg-btn spjs-dlg-btnOK' onclick='customCloseFunc()' value='OK'>",
          "noBtn": true
      });
      
      function customCloseFunc() {
          var txt = jQuery("#myTextarea").val();
          var num = jQuery("#myNumber").val();
          if (txt !== "" && num !== "") {
              // Save OK - continue with your code
              spjs.dffs.closeDlg();
          } else {
              jQuery("#myFormValidation").show();
          }
      }

      Alexander

Viewing 1 reply thread
  • You must be logged in to reply to this topic.