How to remove whitespace on MVC Create or Edit view page?

rogersb 21 Reputation points
2021-07-28T17:45:32.113+00:00

Using asp.net 4.7 C# mvc
Have a typical CRUD application, sometimes the user may input whitespace into a textbox.

one solution is to write javascript to manage each of the textboxes and remove whitespace to accomplish what textboxitem.trim(); does?

Is there a newer or better way to remove user white space at POST time?

thanks

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,481 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 65,131 Reputation points
    2021-07-29T04:28:14.317+00:00

    Simple JavaScript & jQuery

    $(document).on(“blur”,”:input”,function() {
        this.value = this.value.trim();
    });
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.