Last active
May 23, 2023 07:23
-
-
Save contensis/cdd4d16452e73eafc5ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using Contensis.Framework.Web | |
@{ | |
AppContext.Current.Page.Scripts.Add("/siteelements/scripts/jqueryvalidate/jquery.validate.js"); | |
AppContext.Current.Page.Scripts.Add("/siteelements/scripts/jqueryvalidate/jquery.validate.unobtrusive.js"); | |
// define some validation rules against fields within the Form | |
Validation.Add("Username", | |
Validator.Required("You must provide a username"), | |
Validator.StringLength(10, 0, "No more than 10 letters") | |
); | |
Validation.RequireField("Firstname", "Firstname is required"); | |
Validation.Add("Email", | |
Validator.Regex(@"^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$", | |
"Invalid format for an email address") | |
); | |
} | |
… | |
@using (Html.BeginContensisForm("MyAction", "api/MyApiController")) | |
{ | |
@Html.ValidationSummary("Validation Summary", new { @class = "validation-summary-class" }) | |
<div class="form-group"> | |
<label for="firstname">Firstname:</label> | |
@Html.TextBox("Firstname", null, new { @type = "email", @class = "form-control" }) | |
</div> | |
… | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment