Created
February 5, 2013 21:53
-
-
Save cleytonferrari/4718095 to your computer and use it in GitHub Desktop.
Código do post em meu blog
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
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( | |
"~/Scripts/jquery.unobtrusive*", | |
"~/Scripts/jquery.validate*", | |
"~/Scripts/methods_pt.js")); |
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
PM> Install-Package Microsoft.AspNet.Mvc.pt-br |
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
@model ValidandoDataeMoeda.Models.Produto | |
@{ | |
ViewBag.Title = "Index"; | |
} | |
<h2>Validando Data e Moeda em ASP.Net MVC 4</h2> | |
@using (Html.BeginForm()) { | |
@Html.ValidationSummary(true) | |
<fieldset> | |
<legend>Produto</legend> | |
<div class="editor-label"> | |
@Html.LabelFor(model => model.Nome) | |
</div> | |
<div class="editor-field"> | |
@Html.EditorFor(model => model.Nome) | |
@Html.ValidationMessageFor(model => model.Nome) | |
</div> | |
<div class="editor-label"> | |
@Html.LabelFor(model => model.Validade) | |
</div> | |
<div class="editor-field"> | |
@Html.EditorFor(model => model.Validade) | |
@Html.ValidationMessageFor(model => model.Validade) | |
</div> | |
<div class="editor-label"> | |
@Html.LabelFor(model => model.Valor) | |
</div> | |
<div class="editor-field"> | |
@Html.EditorFor(model => model.Valor) | |
@Html.ValidationMessageFor(model => model.Valor) | |
</div> | |
<p> | |
<input type="submit" value="Create" /> | |
</p> | |
</fieldset> | |
} | |
@section Scripts { | |
@Scripts.Render("~/bundles/jqueryval") | |
} |
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 System.Web.Mvc; | |
using ValidandoDataeMoeda.Models; | |
namespace ValidandoDataeMoeda.Controllers | |
{ | |
public class HomeController : Controller | |
{ | |
public ActionResult Index() | |
{ | |
return View(); | |
} | |
[HttpPost] | |
public ActionResult Index(Produto produto) | |
{ | |
return View(produto); | |
} | |
} | |
} |
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
/* | |
* Localized default methods for the jQuery validation plugin. | |
* Locale: PT_BR | |
*/ | |
jQuery.extend(jQuery.validator.methods, { | |
date: function (value, element) { | |
return this.optional(element) || /^\d\d?\/\d\d?\/\d\d\d?\d?$/.test(value); | |
}, | |
number: function (value, element) { | |
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:,\d+)?$/.test(value); | |
} | |
}); |
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
public class Produto | |
{ | |
public string Nome { get; set; } | |
public DateTime Validade { get; set; } | |
public decimal Valor { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment