Ignore fields to be validated using jquery.validate. 1.8.1

Asked

Viewed 96 times

0

I have a project at the company where I am interning and I have had some errors when validating inputs. Use ASP.NET MVC, Razor, and Javascript. When submitting all fields I get an error. Using the Chrome console I found that this field:

@Html.HiddenFor(m => m.Material.DateCreated)

It is not valid. When I went to see the value, it was correct so I don’t think I need to validate because the value always comes from the controller. What I wanted to do is wear something like this:

$("#myform").validate({
ignore: "#target"
});

It seemed that I had the solution, but in my code what I have is $form.Valid() and I don’t know how to implement this 'ignore' as in the code above because it gives error. From what I researched I think that the version that is in the project is outdated, because I can not find anything in google with Valid(), only appears to me validate().

1 answer

0

The solution I found to my problem was the following:

I took the

@Html.HiddenFor(m => m.Material.DateCreated)

and in the POST action on controller put the current date like this:

Material.DateCreated = DateTime.Now;

The difference now is that I don’t put the date on the GET action and I turned around.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.