My question is about what is necessary and/or best practice.
Suppose, for example I need some text from an input into my controller, and that text isn't to be blank.
<form action="BaHumBug/Index" method="post" id="xmasTextForm">
<input name="xmasText" type="text" id="xmasTextInput" />
</form>
Do I enforce the rule about no empty text on the client side
$('#xmasTextForm').submit(function(ev) {
{
if ($('#xmasTextForm').val().isWhiteSpace())
{
alert("Fill the input with something, dude!");
return false;
}
}
or the server side
[HttpPost]
public ActionResult Index (string xmasText)
{
if (xmasText.IsWhiteSpace())
{
// ....
}
or do I do both for 2 layers of protection? Or does the choice depend on other factors?