CA Service Management

 View Only
  • 1.  How to customize the error message the users sees from a screen validation?

    Posted May 05, 2017 02:07 PM

    I have a form with the following components:
          radio group (with 3 radio buttons)
          text area
          select1
          select2
          select3

     

    select1,2,3 are hidden/unhidden with a javascript based on the selection within the radio group and this works fine.  My problem is the text area.


    It is a required field, but validation does not happen until the user presses 'Add to Cart'.  If the text area is empty at that point, it shows a generic error message:
         There is a validation error on the page, please fix it before continuing.

     

    I have tried adding a javascript function to the 'onValidate' attribute of the text area, but that doesn't execute at all because the user is skipping over the text area and clicking in the select box.

    How can I change the message to be more specific?

     

    Thanks!



  • 2.  Re: How to customize the error message the users sees from a screen validation?

    Posted May 05, 2017 02:18 PM

    You can create your own validation function and call it onSubmit of your form.

     

    The function must return true or false.



  • 3.  Re: How to customize the error message the users sees from a screen validation?

    Posted May 05, 2017 03:02 PM

    Thanks for the quick reply!

     

    I have tried doing that, but it didn't work.  Here's what I did, maybe you can see what I'm doing wrong!

     

    To the onSubmit attribute for the form I added the javascript function:

     

    Here's my text_area info:

     

     

    To the form script I added the function logic:

            validateUsageDescription : function (usageDesc) {
               if( !usage_description || usage_description.length === 0 || usage_description === "") {
                   alert("Please enter usage description");
               } 
           },

     

    When I test this, I am still getting the same generic error message as before.

     

    Thanks!



  • 4.  Re: How to customize the error message the users sees from a screen validation?

    Posted May 05, 2017 03:06 PM

    try

     

     

    validateUsageDescription : function () {

    var value = ca_fdGetTextFieldValue(ca_fd.formId,'usage_description');
               if( typeof value === "undefined" || value === "") {
                   alert("Please enter usage description");
               } 
           },

     

     

     

    EDIT : removed parameter from the function



  • 5.  Re: How to customize the error message the users sees from a screen validation?

    Posted May 05, 2017 03:39 PM

    Hey, sorry for the slackness, I should know better!

     

    Any way, I made those changes and still got the same error message so I added alerts:

     

    validateUsageDescription : function () {
             alert("usage reached");
             var value = ca_fdGetTextFieldValue(ca_fd.formId,'usage_description');
             alert("myValue=" + value);
               if( typeof value === "undefined" || value === "") {
                   alert("Please enter usage description");
               }
           },

     

    None of the alerts are displaying so I'm guessing I've gotten something else out of kilter, but I can't see it.



  • 6.  Re: How to customize the error message the users sees from a screen validation?
    Best Answer

    Posted May 05, 2017 03:46 PM

    After a quick test,

     

    Catalog does validate if every required field is provided before executing your onSubmit function. 

     

    Set your textarea as required:false and your code will work



  • 7.  Re: How to customize the error message the users sees from a screen validation?

    Posted May 08, 2017 07:35 AM

    Setting the textarea required attribute to 'false' worked!!  This combined with getting the script code right (as you indicated above) were the correct answer.

     

    Thank you so very much!!!