Display warning message

RadhaKrishnaKiJaya
RadhaKrishnaKiJaya used Ask the Experts™
on
Hi Experts,
My view model has this code.


[Required]
[StringLength(50, ErrorMessage = "Your business email address may not exceed 50 characters.")]
[Email]
[DataType(DataType.EmailAddress)]
[DisplayName("Business email")]
public string BusinessEmail { get; set; }

Open in new window



is it possible to add another  'not Required'  warning message when the EmailAddress contains a commercial domain. (For ex: if the email address is "test@yahoo.com" then there should be an warning message.

Please help!!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
DarrenSenior Software Engineer

Commented:
Hi

Could you write your own custom validator for the email address and check both email and check for a set of domain names. You would probably need an exhaustive list of domains.

Thanks,

Darren

Author

Commented:
Yes, I want something like that.
Thanks.
Thank you for trying to help. I found some solution.

<script language="javascript" type="text/javascript">
    jQuery(document).ready(function () {
        jQuery("#BusinessEmail").blur(function () {
            jQuery.ajax({
                type: "POST",
                url: '@Url.Action("NonBusinessDomain", "Enroll")',
                data: '{email: "' + jQuery("#BusinessEmail").val() + '" }',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    if (response == true) {
                        var BusinessEmail = jQuery("#BusinessEmail").val();
                         jQuery("#Business_Email_Msg").show();
                    }
                    else {
                        jQuery("#Business_Email_Msg").hide();
                    }
                }
            });
        });
    });
</script>

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial