Hi, need help on my requirements where in I need to set fields on my form as req

Hi, need help on my requirements where in I need to set fields on my form as required. I have read that advance form utilities will do the trick but however I'm getting error while trying my code. Please see me code below and let me know if I mis something.

if (window.FormAPI.getValue("button1").id=="Create")
{
window.FormAPI.setRequired("text4",true);
window.FormAPI.setRequired("text6",true);
window.FormAPI.setRequired("text9",true);
window.FormAPI.setRequired("text10",true);
window.FormAPI.setRequired("radio22",true);
window.FormAPI.setRequired("dropdown14",true);
}
else
{window.FormAPI.hide("hidden24");}


TIA!...

OriginalPostID-120790

OriginalPostID-120790

  Discussion posts and replies are publicly visible

Parents
  • I use the following JS code. I create a field on the form with the ID "txtValidateForm" (which is hidden onLoad), submit button as "btnSubmit" and cancel button as "btnCancel". onLoad_Form() is called on the form load, required fields each call the validation function as: Return ValidateNotNull("fieldName"); which decides if validation should continue or if it should be bypassed - based on the value set in txtValidateForm by either the Submit or Cancel button just pressed. Cancel sets the txtValidateForm field to No, bypassing validation, where Submit sets the field to Yes which forces each required field to validate. I add a "*" just before each required field name - you can also add an image of a red "*" in there for the same display as a physically required field.

    function onLoad_Form()
    {
              window.FormAPI.hide("txtValidateForm");
              onLoadCancelButton("btnCancel");
              onLoadSubmitButton("btnSubmit");
    }

    function ValidateNotNull(fieldName)
    {
              if(window.FormAPI.getValue("txtValidateForm").id == "YES") return true;

              var data = window.FormAPI.getValue(fieldName).id;
              if(data != "") return true;
              else
              {
                        asi.alert("Fields are Required!");
                        return false;
              }
    }

    function onLoadCancelButton(btnCancel){

    var buttonConfig = window.Build.util.getComponentContainer(btnCancel,window.FormDesigner.runtimeNamespace);

    var clickFunction = function(){
    window.FormAPI.setValue("txtValidateForm","NO");
    };

    buttonConfig[0].firstChild.onkeydown = clickFunction;
    buttonConfig[0].firstChild.onmousedown = clickFunction;
    }


    function onLoadSubmitButton(btnSubmit){

    var buttonConfig = window.Build.util.getComponentContainer(btnSubmit,window.FormDesigner.runtimeNamespace);

    var clickFunction = function(){
    window.FormAPI.setValue("txtValidateForm","YES");
    };

    buttonConfig[0].firstChild.onkeydown = clickFunction;
    buttonConfig[0].firstChild.onmousedown = clickFunction;
    }
Reply
  • I use the following JS code. I create a field on the form with the ID "txtValidateForm" (which is hidden onLoad), submit button as "btnSubmit" and cancel button as "btnCancel". onLoad_Form() is called on the form load, required fields each call the validation function as: Return ValidateNotNull("fieldName"); which decides if validation should continue or if it should be bypassed - based on the value set in txtValidateForm by either the Submit or Cancel button just pressed. Cancel sets the txtValidateForm field to No, bypassing validation, where Submit sets the field to Yes which forces each required field to validate. I add a "*" just before each required field name - you can also add an image of a red "*" in there for the same display as a physically required field.

    function onLoad_Form()
    {
              window.FormAPI.hide("txtValidateForm");
              onLoadCancelButton("btnCancel");
              onLoadSubmitButton("btnSubmit");
    }

    function ValidateNotNull(fieldName)
    {
              if(window.FormAPI.getValue("txtValidateForm").id == "YES") return true;

              var data = window.FormAPI.getValue(fieldName).id;
              if(data != "") return true;
              else
              {
                        asi.alert("Fields are Required!");
                        return false;
              }
    }

    function onLoadCancelButton(btnCancel){

    var buttonConfig = window.Build.util.getComponentContainer(btnCancel,window.FormDesigner.runtimeNamespace);

    var clickFunction = function(){
    window.FormAPI.setValue("txtValidateForm","NO");
    };

    buttonConfig[0].firstChild.onkeydown = clickFunction;
    buttonConfig[0].firstChild.onmousedown = clickFunction;
    }


    function onLoadSubmitButton(btnSubmit){

    var buttonConfig = window.Build.util.getComponentContainer(btnSubmit,window.FormDesigner.runtimeNamespace);

    var clickFunction = function(){
    window.FormAPI.setValue("txtValidateForm","YES");
    };

    buttonConfig[0].firstChild.onkeydown = clickFunction;
    buttonConfig[0].firstChild.onmousedown = clickFunction;
    }
Children
No Data