- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 06-25-2015 05:21 PM
The need for checking for error messages as I wanted to perform an onload function based on whether there is an error message after form submission or not. Checking through the wiki did not give me any handy reference to client side error message. I even checked the g_form.hasFieldMsgs method but it was not picking up though it was a handy reference. Written below is a script you can use on your client side to check for any field message error and info. Feel free to modify as you use it.
function formHasFieldMsgs() {
var formHasFieldMsgs = false;
var msgTRsInfo = $(document.body).select('[class$="info"]')
var msgTRsError = $(document.body).select('[class$="error"]') // class$ checks for any class ending in error
if ( msgTRsInfo.length > 0 || msgTRsError.length > 0)
formHasFieldMsgs = true;
return formHasFieldMsgs;
}
- 4,989 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Exactly what I needed. Even works in Agent Workspace!
Any way to search for a specific field message or a field message on a specific field?
Super thanks!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi @ctsmith,
I used alternate way of setting Label field with suffix when error and then verify Label contains that suffix to check if field in form contains any Field error msgs
- onChange client script invoke function from Script Include to pass parameters
- Script Include will return answer after validating parameters
- onChange client script will set label values and field messages based on answer
var answer = response.responseXML.documentElement.getAttribute("answer");if (answer == 'Error') {
g_form.setLabelOf('assignment_group', 'Assignment group?');
g_form.showFieldMsg('assignment_group', "Assignment Group warning msg", 'error');
} - onSubmit client script will check if Label of field contains suffix
var groupLabel = g_form.getLabelOf('assignment_group');
if (groupLabel == 'Assignment group?') {
// notify field error msg was here
}
If you find my comment useful, mark it as correct or helpful.
Regards,
Deepak Ramar