public static MvcHtmlString TextBoxMask <TModel>(this HtmlHelper <TModel> htmlHelper, string name, string value, string[] masks, bool formatInRender = false, object htmlAttributes = null) { MaskAttribute maskAttribute = new MaskAttribute(masks, true, formatInRender); IDictionary <string, object> dictionaryHtmlAttributes = new Dictionary <string, object>(); if (htmlAttributes != null) { dictionaryHtmlAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); } dictionaryHtmlAttributes.Add("data-mask-templete", Json.Encode(maskAttribute.MaskTemplete)); if (maskAttribute.FormatInRender) { value = maskAttribute.Format(value); } return(htmlHelper.TextBox(name, value, dictionaryHtmlAttributes)); }
public void Format_MultMask_CNPJ_Test() { MaskAttribute mask = new MaskAttribute(new string[] { "99.999.999/9999-99", "999.999.999-99" }); Assert.AreEqual("68.837.346/0001-82", mask.Format("68837346000182")); }
public static MvcHtmlString LabelMask <TModel>(this HtmlHelper <TModel> htmlHelper, string name, string value, MaskAttribute mask, object htmlAttributes = null) { value = mask.Format(value); return(htmlHelper.Label(name, value, htmlAttributes)); }
public void Format_INT_Test() { MaskAttribute mask = new MaskAttribute("999"); Assert.AreEqual("1", mask.Format("1")); }
public void Format_Lat_Long_Test() { MaskAttribute mask = new MaskAttribute("+00°00'00.000\""); Assert.AreEqual("+60°58'35.100\"", mask.Format("605835100")); }
public void Format_End_Test() { MaskAttribute mask = new MaskAttribute("99.99+++++"); Assert.AreEqual("12.34+++++", mask.Format("1234")); }
public void Format_CPF_Test() { MaskAttribute mask = new MaskAttribute("999.999.999-99"); Assert.AreEqual("079.924.746-43", mask.Format("07992474643")); }
public void Format_CNPJ_Test() { MaskAttribute mask = new MaskAttribute("99.999.999/9999-99"); Assert.AreEqual("68.837.346/0001-82", mask.Format("68837346000182")); }
public void Format_MultMask_Telefone_9_Dig_Test() { MaskAttribute mask = new MaskAttribute(new string[] { "(99) 9999-9999", "(99) 99999-9999" }); Assert.AreEqual("(31) 98742-3236", mask.Format("31987423236")); }
public void Format_MultMask_CPF_Test() { MaskAttribute mask = new MaskAttribute(new string[] { "99.999.999/9999-99", "999.999.999-99" }); Assert.AreEqual("079.924.746-43", mask.Format("07992474643")); }