Guest User

Untitled

a guest
Apr 24th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <div class="d-1of2 t-1of2 m-all">
  2. @Html.LabelFor(m => m.FirstName)
  3. @Html.MaxLengthTextBoxFor(m => m.FirstName, new { @class = "alphaonly" })
  4. @Html.ValidationMessageFor(m => m.FirstName)
  5. </div>
  6.  
  7. [Required]
  8. [Display(Name = "First Name")]
  9. [StringLength(100)]
  10. public string FirstName { get; set; }
  11.  
  12. <div class="d-1of2 t-1of2 m-all">
  13. <label for="FirstName">First Name</label>
  14. <input class="alphaonly" data-val="true" data-val-length="The field First Name must be a string with a maximum length of 100." data-val-length-max="100" data-val-required="The First Name field is required." id="FirstName" maxlength="100" name="FirstName" type="text" value="" />
  15. <span class="field-validation-valid" data-valmsg-for="FirstName" data-valmsg-replace="true"></span>
  16. </div>
  17.  
  18. function onError(error, inputElement) { // 'this' is the form element
  19. var container = $(this).find("[data-valmsg-for='" + escapeAttributeValue(inputElement[0].name) + "']"),
  20. replaceAttrValue = container.attr("data-valmsg-replace"),
  21. replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) !== false : null;
  22.  
  23. container.removeClass("field-validation-valid").addClass("field-validation-error");
  24. error.data("unobtrusiveContainer", container);
  25.  
  26. if (replace) {
  27. container.empty();
  28. error.removeClass("input-validation-error").appendTo(container);
  29. }
  30. else {
  31. error.hide();
  32. }
  33. }
Add Comment
Please, Sign In to add comment