jQuery或Javascript输入IP地址掩码 [英] JQuery or Javascript Input IP address mask
本文介绍了jQuery或Javascript输入IP地址掩码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经按照stackoverflow问题使用了jquery屏蔽输入插件
I have used jquery masked input plugin as per stackoverflow question
但这对我没有用.
我像$("input").mask("9?99.9?99.9?99.9?99", {placeholder:" "});
我发现了这个演示( http://jsfiddle.net/3F2gM/3/)在上一个问题中,但是没有用
This demo (http://jsfiddle.net/3F2gM/3/ ) i found in previous question , but it didnt works
推荐答案
以这种方式为我工作:
首先,我在html中添加了jquery-mask:
First, I added jquery-mask in the html:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.10/jquery.mask.js"></script>
然后,我使用.ip_address类键入文本字段:
Then I typed the text field with the class .ip_address:
<label>ip:</label> <input class="ip_address" type="text" name="ip">
最后一次:
$('.ip_address').mask('0ZZ.0ZZ.0ZZ.0ZZ', { translation: { 'Z': { pattern: /[0-9]/, optional: true } } });
这篇关于jQuery或Javascript输入IP地址掩码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文