Hi,
Add the following code lines to verify the errors.
var thisXDocument = null;
thisXDocument = window.external.Window.XDocument;
if (thisXDocument.Errors.Count > 0)
{
alert("Please fill the required fields.");
return;
}
Else
{
Write your code here
}