MVC Model Validation not working

Posted by: dmwysocki on 21 March 2018, 12:00 pm EST

    • Post Options:
    • Link

    Posted 21 March 2018, 12:00 pm EST

    I have an evaluation license. I have a numeric currency field which works fine except for the fact the field is required via model validation. Validation works fine if I don’t have the component one attribute enabled. With the component one attribute enabled, I receive the required error message even though I have entered a value in the field. How do I make component one and mvc validation work together?

  • Posted 21 March 2018, 11:11 pm EST

    Hi,

    We are looking into this.

    ~Manish

  • Posted 26 March 2018, 10:50 pm EST

    Hi,

    We are sorry for the delayed response.

    Probably, the error you are getting while you are using validation for new record creation. If yes, please set IsRequired to false in this case.

    Since, on creating control do not get any value as default and throw error. Please refer to the following code snippet:

    <div class="form-group">
               @Html.LabelFor(model => model.Age, htmlAttributes: new { @class = "control-label col-md-2" })
               <div class="col-md-10">
                   
                   @Html.C1().InputNumberFor(model=>model.Age).IsRequired(false)
                   @Html.ValidationMessageFor(model => model.Age, "", new { @class = "text-danger" })
               </div>
           </div>
    

    ~Manish

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels