My query pertains to the necessity and/or best practices.
Let's say I require some text from an input in my controller, with the condition that it cannot be blank.
<form action="BaHumBug/Index" method="post" id="xmasTextForm">
<input name="xmasText" type="text" id="xmasTextInput" />
</form>
Should I enforce the non-empty text rule on the client side
$('#xmasTextForm').submit(function(ev) {
{
if ($('#xmasTextForm').val().isWhiteSpace())
{
alert("Fill the input with something, dude!");
return false;
}
}
or on the server side?
[HttpPost]
public ActionResult Index (string xmasText)
{
if (xmasText.IsWhiteSpace())
{
// ....
}
Or should I implement both for dual protection layers? Or does the decision depend on other criteria?