Microsoft Office Tutorials and References
In Depth Information
Writing event validation for an expense report form
// Ensure that the constraint you are enforcing is compatible
// With the default value you set for this XML node.
string strManagerEmail = e.Site.SelectSingleNode("/my:
expenseReport/my:manager/my:managerEmailAddress",
NamespaceManager).InnerXml;
// valiadting the Email format
if (!isEmail(strManagerEmail))
{
if (strManagerEmail == string.Empty || strManagerEmail == "")
{
// Validation message
e.CancelableArgs.Message = "Please enter a valid
E-Mail";
e.CancelableArgs.Cancel = true;
}
}
}
// Function to validate Email
public static bool isEmail(string inputEmail)
{
// Regular expression for Email
string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
Regex reg = new Regex(strRegex);
// Compare the regular expression
if (reg.IsMatch(inputEmail))
return (true);
else
return (false);
}
public void managerName_Changed(object sender, XmlEventArgs e)
{
string StrManagerName = "";
// Check if value has changed and not a table insertion
if (e.Operation == XmlOperation.ValueChange)
{
// Get Current Row
XPathNavigator xNavigator = e.Site;
bool bParent = xNavigator.MoveToParent();
// Get Reference to the Gross Value
 
Search JabSto ::




Custom Search