This project has moved and is read-only. For the latest updates, please go here.

Get error

May 26, 2014 at 9:29 PM
Hi

I am trying to know if the page returns error.
I did a check fields by javascript, and when it return a error, i would like to get this error, and make something in javascript

Is it possible?
May 27, 2014 at 2:37 AM
thiagoluga,
Can you explain more about what you're trying to achieve? Also, if you post your code it is helpful.

I think you're talking about using a try/catch block. See here for an example:
https://github.com/kitmenke/sputility/blob/master/examples/contenttype.html

Thanks,
Kit
May 27, 2014 at 3:50 PM
Hi

When i try to save the New Item:
Image

There is a validation. If the field is empty, it will show a error:
Image

I want to detect this error in javascript, to do something.

Thanks
Jun 2, 2014 at 1:04 AM
thiagoluga,
The error messages look something like this:
<span id="Error_Title_fa564e0f-0c70-4ab9-b863-0177e6ddd247_$TextField" class="ms-formvalidation ms-csrformvalidation"><span role="alert">You can't leave this blank.<br></span></span>
This means you can put together a jQuery selector to find these elements on the page. For example: $('span.ms-formvalidation')

You can check the count to see how many elements there are: $('span.ms-formvalidation').length and if it is more than 0 then you know there is an error.
Thanks,
Kit
Jun 3, 2014 at 6:09 PM
Thanks

It works =D