Question

Live example: http://mvc.renethomassen.dk/

I have used jQuery unobtrusive validation with data annotations (MVC 4), when I publish my website, properties with multiple annotations do not work, validate.

This works:

[Required(ErrorMessage = "Skriv venligst dit navn")]
public string Navn { get; set; }

The following does not work (it works on localhost). Why?

[Required(ErrorMessage = "Skriv venligst din emailadresse")]
[EmailAddress(ErrorMessage="Angiv en gyldig emailadresse")]
public string EmailAdresse { get; set; }
Was it helpful?

Solution

Try using DataTypeAttribute instead of EmaillAddressAttribute

[Required(ErrorMessage = "Skriv venligst din Emailadresse")]
[DataType(DataType.EmailAddresss, ErrorMessage = "Angiv en gyldig email")]
public string EmailAdresse { get; set; }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top