So many ways to do this with JS, but the easiest is to use the Application.IsDestinationReachable method to programatically see if the file already exists in SharePoint. Try this code:
myFileNameField = XDocument.DOM.selectSingleNode("//fileNameField").text;
myURL = "http://mySite/library/"+myFileNameField + ".xml";
if (Application.IsDestinationReachable(myURL)) submitFormWithMySubmitConnection();
else XDocument.UI.Alert("file name already exists");
You could also create a new data connection to the library to receive data from a SharePoint library or list and traverse the list to see if the file name already appears, but I think that's a bit code heavy.