mercredi 21 septembre 2016

Model Validations in Tool Tip in MVC - aspx engine

I need to change the hard coded validation "Agent Name is Required" to Dynamic. This validation should be pulled from model.

I am displaying the hardcoded value in a Tool tip. Want to display multiple messages from Model as Email invalid Format and Email Required

  <div class="form-group">
    <label class="control-label"><%:Resources.Labels.IAName%></label>
    <i class="glyphicon glyphicon-asterisk glyphicon-required"></i>
    <%= Html.TextBoxFor(m =>  m.IAName, new {title="Agent Name is Required", @class ="IALoanInfo", maxlength="50"}) %>
  </div>

    $('.IALoanInfo').tooltip();
    $(function () {
        $('.IALoanInfo').on('shown.bs.tooltip', function () {
            $('.tooltip').addClass('animated fadeInUp');
        })
    })

Model

    [Required(ErrorMessageResourceName = "EmailAddressRequiredError", ErrorMessageResourceType = typeof(Resources.Labels))]
    [DataType(DataType.EmailAddress, ErrorMessage = "EmailAddressRequired")]
    [RegularExpression(@"[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}", ErrorMessage = "Invalid Email-Address")]
    public string InsuranceAgentEmail { get; set; }  

Aucun commentaire:

Enregistrer un commentaire