Validation for Popup Form

Validation for Popup Form

tdktdk Posts: 32Questions: 16Answers: 0

I'm not using the client side validation so when my form submits my server side validation returns a JSON response containing the following.

{  
   "Name":{  
      "ChildNodes":null,
      "Children":null,
      "Key":"Name",
      "SubKey":{  
         "Buffer":"Name",
         "Offset":0,
         "Length":4,
         "Value":"Name",
         "HasValue":true
      },
      "IsContainerNode":false,
      "RawValue":null,
      "AttemptedValue":null,
      "Errors":[  
         {  
            "Exception":null,
            "ErrorMessage":"'Name' must be between 3 and 60 characters. You entered 0 characters."
         }
      ],
      "ValidationState":1
   }
}

What I'd like to do is display the ErrorMessage on the popup form. Is this possible?

Answers

  • allanallan Posts: 63,356Questions: 1Answers: 10,447 Site admin

    Is this in Editor? If so, the manual details the responses that Editor expects to be able to have it show error information. If you'd like to return something other than that data structure (such as the above) you would need to use postSubmit to modify the data into the format Editor expects.

    Regards,
    Allan

  • tdktdk Posts: 32Questions: 16Answers: 0

    Hi Allan, thanks for the reply. I notice there are 3 divs which supposedly display info or error messages. In my postSubmit how would I utilise these divs?

    <div data-dte-e="msg-error" class="help-block"></div>
    <div data-dte-e="msg-message" class="help-block"></div>
    <div data-dte-e="msg-info" class="help-block"></div>
    
  • allanallan Posts: 63,356Questions: 1Answers: 10,447 Site admin

    You'd need to morph the JSON returned from the server into the structure expected by Editor. Editor will then populate those elements as required.

    Regards,
    Allan

This discussion has been closed.