I have 3 phone fields and any one is required. SO i had a custom validation class to make any one of them is required. And i am calling those class as follows
[RegularExpression(@"^\(?([0-9]{3})\)?. ]?([0-9]{3})[-. ]?([0-9]{4})$", ErrorMessage = "Entered phone format is not valid. <br/> 10 digits are required.<br/> No spaces between digits. <br/> Numbers only.")]
[AtLeastOneRequired("PhoneHome", "PhoneMobile", "PhoneOffice", ErrorMessage = "Please provide either of PhoneHome or PhoneMobile or phoneOffice. ")]
public string PhoneHome { get; set; }
[StringLength(11, MinimumLength = 10)]
[RegularExpression(@"^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$", ErrorMessage = "Entered phone format is not valid. <br/> 10 digits are required.<br/> No spaces between digits. <br/> Numbers only.")]
[Display(Name = "Prompt_PhoneOffice", ResourceType = typeof(ResContactItems))]
public string PhoneOffice { get; set; }
[StringLength(11, MinimumLength = 10)]
[RegularExpression(@"^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$", ErrorMessage = "Entered phone format is not valid. <br/> 10 digits are required.<br/> No spaces between digits. <br/> Numbers only.")]
[Display(Name = "Prompt_PhoneMobile", ResourceType = typeof(ResContactItems))]
public string PhoneMobile { get; set; }
The problem is with only "PhoneHome " field , if i enter incorrect format, it will display error message based ont he regular expression given .But the regular expression message is not disappearing wwhen we enter the correct format too.It will disappear only in f the field is empty.Other two fields are showing properly. Is this due to the custom class i am calling.?
Please help me to sort out this issue
Thanks,
Vidya