Read "How to debug a script for a Microsoft Office InfoPath 2003 form" (MSKB Article 827002; http://support.microsoft.com/kb/827002/EN-US/) to see, "To debug a script for an InfoPath form, you must first attach Microsoft Script Debugger to your InfoPath form." In JScript it's:
debugger;
Alternatively, the alert() function can be accessed by
XDocument.UI.Alert("Hello world.");
Read "How to create a custom validation error message that contains the name of the control that is being validated in InfoPath 2003" (MSKB Article 822032; http://support.microsoft.com/kb/822032/EN-US/) to see how a validation event procedure is designed.
Consult the "InfoPath Object Model Diagram" at:
http://msdn.microsoft.com/library/en-us/ipsdk/html/xdtocInfoPathObjectModel.asp