how to validate hidden doms

mc 5,426 Reputation points
2023-05-29T09:27:54.4433333+00:00

I have a hidden value

<input type="hidden" asp-for="ImageUrl" />

<span asp-validator-for="ImageUrl" />

how to validate it?

jquery.validate will not validate the hidden doms.

Developer technologies | ASP.NET | ASP.NET Core
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-05-30T20:39:30.9+00:00

    to validate hidden fields, update the ignore selector which defaults to ":hidden".

    $('#myForm').validate().settings.ignore = ".ignore"; // require ignore class to ignore
    
    

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.