Input mask MVC unmask in controller

杀马特。学长 韩版系。学妹 提交于 2019-12-12 05:27:31

问题


Im working in MVC 5.2 .NET 4.5:

Can anyone point me to a js or other library / method for an input mask that will unmask and just send the entered data in the view model to the controller?

Any .js library I've tried so far that can unmask, still sends the mask to the controller.

Thank you.


回答1:


https://github.com/RobinHerbots/jquery.inputmask

Set autoUnmask to true for client side validation and removeMaskOnSubmit to true to get the input with the literals removed in the server side validation or controller.

Example of an editor template using this for a phone number:

@model string

@Html.TextBox("", Model, new { @class = "form-control" })

<script type="text/javascript">

$(function () {
    $('#@Html.IdForModel()').inputmask({ "mask": "(999) 999-9999", 'autoUnmask': true, 'removeMaskOnSubmit': true });
});
</script>


来源:https://stackoverflow.com/questions/27531320/input-mask-mvc-unmask-in-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!