Created
October 30, 2019 16:49
-
-
Save epgarcia/a7cf6d40d47845016e1de2e5d330ebfd to your computer and use it in GitHub Desktop.
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
<%-- | |
/** | |
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. | |
* | |
* This library is free software; you can redistribute it and/or modify it under | |
* the terms of the GNU Lesser General Public License as published by the Free | |
* Software Foundation; either version 2.1 of the License, or (at your option) | |
* any later version. | |
* | |
* This library is distributed in the hope that it will be useful, but WITHOUT | |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | |
* details. | |
*/ | |
--%> | |
<%@ include file="/init.jsp" %> | |
<div class="autofit-row"> | |
<div class="col-md-4"> | |
<aui:input inlineField="<%= true %>" label="from" name="ipFrom" placeholder="192.0.0.1" value="<%= ipRangeRuleDisplayContext.getIpFrom() %>"> | |
<aui:validator name="required" /> | |
<aui:validator errorMessage="invalid-ip-format" name="custom"> | |
function(val, fieldNode, ruleValue) { | |
return validateIpAddress(val); | |
} | |
</aui:validator> | |
</aui:input> | |
</div> | |
<div class="col-md-4"> | |
<aui:input inlineField="<%= true %>" label="to" name="ipTo" placeholder="192.0.0.255" value="<%= ipRangeRuleDisplayContext.getIpTo() %>"> | |
<aui:validator name="required" /> | |
<aui:validator errorMessage="invalid-ip-format" name="custom"> | |
function(val, fieldNode, ruleValue) { | |
return validateIpAddress(val); | |
} | |
</aui:validator> | |
</aui:input> | |
</div> | |
</div> | |
<% | |
String ipv4 = "/^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$/"; | |
String ipv6 = "/^(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}$/"; | |
%> | |
<aui:script> | |
function validateIpAddress(ipAddress) { | |
if (ipAddress.match(<%= ipv4 %>) || ipAddress.match(<%= ipv6 %>)) { | |
return true; | |
} | |
return false; | |
} | |
</aui:script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment