I am working on infopath 2007 browser based form on which on selection of radio button I am adding the error message like below
public void IsGuest_Validating(object sender, XmlValidatingEventArgs e)
{
// Write your code here to change the main data source.
if (e.NewValue == "Yes")
{
XPathNavigator Main = MainDataSource.CreateNavigator();
XPathNavigator Guestname = Main.SelectSingleNode("/my:myFields/my:Guest/my:GuestName", NamespaceManager);
this.Errors.Add(Guestname, "Guestname", "Guestname Cannot be null");
}
else
{
checkErrors("Guestname");
}
}
public void checkErrors(string ErrorName)
{
try
{
this.Errors.Delete(ErrorName);
}
catch (Exception) { }
}
This function add the error messgae when Guest Selected and remove the error message when guest is not selected .I am using submit option through rule and submit to sharepoint library
When use r submit, Problem is mandatory fields have value filled by user even it says (InfoPath cannot submit the form because it contains errors. Errors are marked with either a red asterisk (required fields) or a red, dashed border (invalid values).)
I have tried with IsGuest_Changed event also.
I am not getting why this error come even if user fill the values in mandatory fields.I am using couple of radio button for this type of validation in same form.
Any help please let me know.