I have created a Custom Validation Attribute:
public class FutureDateAttribute : ValidationAttribute
{
public override bool IsValid(object value)
{
if (value == null|| (DateTime)value < DateTime.Now)
return false;
return true;
}
}
How can I get this to work on client side too with jquery?
It took a little while since your question was asked, but if you still like metadata, and you're still open for simplified alternatives, you can solve your problem using following annotations:
It works for both - server and client, out of the box. For further details take a look at ExpressiveAnnotations library.
Here's how to proceed:
Start by defining the custom validation attribute:
Notice how it implements IClientValidatable. Next we write our model:
Then a controller:
and finally a view:
The last part for the magic to happen is to define the custom adapter: