So I wanted to validate a form with JQuery validation, but it seems like JQuery doesnt like working with classes. Here is an example of what I've tried:
My js:
$('#myForm').validate({
rules: {
something: {
required:true
},
'name.first': { //Between qoutes, because JS does not want to run without
required:true
},
'name.last': {
required: true
}
}
});
My model:
public class myModal
{
string something { get; set; }
public name name { get; set; }
}
public class name
{
string first { get; set; }
string last { get; set; }
}
Thanks in advance, Hanno
我很笨,忘了包含一个 JS 文件。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.