Home How to animate modelvalidation in MVC with Javascript?
Reply: 0

How to animate modelvalidation in MVC with Javascript?

Bash
1#
Bash Published in 2018-02-14 09:10:14Z

I´m new here. please be patient with me :)

An open question, if I´m using asp.net MVC model validation. Can I get my @html.ValidationMessageFor to use javascript effects on display when my controller action returns the error message?

CSS i an option, but my question targets javascript on model validation specifically.

I´m aware of unobtrusive javascript and validate.js.

sample code from my view:

@using (Html.BeginForm("Create","Account", FormMethod.Post, new { data_ajax = "false" }))
{
<fieldset>
    @Html.ValidationMessageFor(model => model.email)
    <div class="form-group has-feedback">
        @Html.TextBoxFor(model => model.email, new {@type="email", @class ="form-control", @placeholder="E-post", @required="required"})
        <i class="form-control-feedback fa fa-envelope" aria-hidden="true"></i>
    </div>

And my model validationattribute looks like this:

public class general_customerMetaData
{
    [CreateAccountValidation("isEmailAvailable", "Account", ErrorMessage = "E-postadressen används redan!")]
    public string email { get; set; }
    public string password { get; set; }
    [System.ComponentModel.DataAnnotations.Compare("password", ErrorMessage = "Lösenorden matchar inte")]
    public string passwordValidation { get; set; }
}

My error message gets displayed, but I don't know how to use javascript effects when passing result from the controller to view.

I appreciate all your help and tips.

Thanks in advance people!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.295461 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO