Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. @page "/modelvalidation"
  2. @inherits ModelValidationCode
  3.  
  4. <h1>Form Validation</h1>
  5.  
  6. <p>This component demonstrates a form with a validatable model using the IValidatableObject interface.</p>
  7.  
  8. <div class="form-group row">
  9. <label for="mystring1" class="col-sm-1 col-form-label">My String 1</label>
  10. <div class="col-sm-11">
  11. <input
  12. id="mystring1"
  13. type="text"
  14. class="form-control"
  15. placeholder="Enter My String 1"
  16. bind="@Model.MyString1"
  17. oninput="@(x => Update(x, () => Model.MyString1 = (string) x.Value))" />
  18. <ValidationError Subject="@Model" Property="@nameof(Model.MyString1)" />
  19. </div>
  20. </div>
  21.  
  22. <div class="form-group row">
  23. <label for="mystring2" class="col-sm-1 col-form-label">My String 2</label>
  24. <div class="col-sm-11">
  25. <input
  26. id="mystring2"
  27. type="text"
  28. class="form-control"
  29. placeholder="Enter My String 2"
  30. bind="@Model.MyString2"
  31. oninput="@(x => Update(x, () => Model.MyString2 = (string) x.Value))" />
  32. <ValidationError Subject="@Model" Property="@nameof(Model.MyString2)" />
  33. </div>
  34. </div>
  35.  
  36. <div class="form-group row">
  37. <label for="myint1" class="col-sm-1 col-form-label">My Int 1</label>
  38. <div class="col-sm-11">
  39. <input
  40. id="myint1"
  41. type="number"
  42. class="form-control"
  43. placeholder="Enter My Int 1"
  44. bind="@Model.MyInt1"
  45. oninput="@(x => Update(x, () => Model.MyInt1 = string.IsNullOrWhiteSpace((string) x.Value) ? 0 : Convert.ToInt32((string) (x.Value ?? "0"))))"/>
  46. <ValidationError Subject="@Model" Property="@nameof(Model.MyInt1)" />
  47. </div>
  48. </div>
  49.  
  50. <div class="form-group row">
  51. <label for="myint2" class="col-sm-1 col-form-label">My Int 2</label>
  52. <div class="col-sm-11">
  53. <input
  54. id="myint2"
  55. type="number"
  56. class="form-control"
  57. placeholder="Enter My Int 2"
  58. bind="@Model.MyInt2"
  59. oninput="@(x => Update(x, () => Model.MyInt2 = string.IsNullOrWhiteSpace((string) x.Value) ? 0 : Convert.ToInt32((string) (x.Value ?? "0"))))" />
  60. <ValidationError Subject="@Model" Property="@nameof(Model.MyInt2)" />
  61. </div>
  62. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement