testmail 1993 testmail 1993 - 5 months ago 28
Javascript Question

Jquery plugin input field to accept more than one IP address

I'm trying to use a Jquery plugin for handling IPV4 addresses. Plugin is available at https://github.com/felipevolpatto/jquery-input-ip-address-control

The issue is I can use only one text field for IPV4 address. If I use one more, I could see only normal text field with out any separators. How can I use it for more than one text field for IPV4 address?

Code:

<form role="form">

<div class="form-group">
<label>Starting Address</label></br>
<input type="text" name="ip1" id="ipv4">

</div>
<div class="form-group">
<label>Ending Address</label></br>
<input type="text" name="ip2" id="ipv4">
</div>


</form>
<script src="js/jquery.input-ip-address-control-1.0.min.js"></script>
<script>
$(function(){
$('#ipv4').ipAddress();
});
</script>

Answer

You cannot use same id in this case. Change id="ipv4" to class="ipv4" and try

$(function(){
        $('.ipv4').ipAddress();
    });