Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am using some code (like the following) to create a form:
Html.EnableClientValidation(); Html.EnableUnobtrusiveJavaScript(); Html.RequiresJs("/umbraco_client/ui/jquery.js"); Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js"); Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js"); var someModel = new SomeModel(); using (Html.BeginUmbracoForm<SomeController>("SomeMethod")) { @Html.ValidationSummary("someModel", true) <div> @Html.LabelFor(m => someModel.RandomProperty) @Html.PasswordFor(m => someModel.RandomProperty) @Html.ValidationMessageFor(m => someModel.RandomProperty) </div> <button>Submit</button> }
It works, but jQuery throws an error:
Uncaught Error: Syntax error, unrecognized expression: :input[name=someModel.RandomProperty]
The property that it is referencing looks like this:
[Required] [Display(Name = "Some Prop")] [Compare("OtherProp", ErrorMessage = "These should match.")] public string RandomProperty { get; set; }
Removing the Compare data attribute "fixes" the error, but I want to be able to use this attribute!
Compare
I will note that nothing breaks... there's just an error in the JS-console. The property is properly "compared" and my c# code keeps-on-goin'.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
CompareAttribute data annotation causes jQuery error with `BeginUmbracoForm` and client validation
I am using some code (like the following) to create a form:
It works, but jQuery throws an error:
The property that it is referencing looks like this:
Removing the
Compare
data attribute "fixes" the error, but I want to be able to use this attribute!I will note that nothing breaks... there's just an error in the JS-console. The property is properly "compared" and my c# code keeps-on-goin'.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.