?? validate.js
字號:
if (requireRadios (form, "fwWebAction", "what to apply") == -1) return false; }return true;}//check the input form for editing or adding on submitfunction checkEditForm(form){// alert("Edit form being checked");// check fwWebDirectionif (requireRadios (form, "fwWebDirection", "Direction") == -1) return false;// check protocol selectionif (requireRadios (form, "fwWebProtoDisplay", "Protocol") == -1) return false;// if you want to check rule name:// - uncomment the next 2 lines of code, and// - edit validateName() function to specify the chars NOT allowed in// rule name// if (! validateName (form.fwWebNameDisplay))// return false;// check all IP addressesif( !checkAddr(form.fwWebSrcAddrStartDisplay) || !checkAddr(form.fwWebSrcAddrEndDisplay) || !checkAddr(form.fwWebDstAddrStartDisplay) || !checkAddr(form.fwWebDstAddrEndDisplay) ) return false;// compare start and end IP addressesif( CompareIP (form.fwWebSrcAddrStartDisplay.value, form.fwWebSrcAddrEndDisplay.value) > 0) { alert("Source start IP address greater than end IP address, please re-enter"); return false; }if( CompareIP (form.fwWebDstAddrStartDisplay.value, form.fwWebDstAddrEndDisplay.value) > 0) { alert("Destination start IP address greater than end IP address, please re-enter"); return false; }// check all port numbers if( !checkPort(form.fwWebSrcPortStartDisplay) || !checkPort(form.fwWebSrcPortEndDisplay) || !checkPort(form.fwWebDstPortStartDisplay) || !checkPort(form.fwWebDstPortEndDisplay) ) return false;// compare start and end port numbersif ( parseInt(form.fwWebSrcPortStartDisplay.value) > parseInt(form.fwWebSrcPortEndDisplay.value) ) { alert("Source start port" + form.fwWebSrcPortStartDisplay.value+ " greater than end port" + form.fwWebSrcPortEndDisplay.value +", please re-enter"); return false; }if ( parseInt(form.fwWebDstPortStartDisplay.value) > parseInt(form.fwWebDstPortEndDisplay.value) ) { alert("Destination start port" + form.fwWebDstPortStartDisplay.value+ " greater than end port" + form.fwWebDstPortEndDisplay.value +", please re-enter"); return false; }// check the anytime selectionvar timeSelection = requireRadios (form, "fwWebNotAnytime", "Time of Day")if (timeSelection == -1) return false;// if select specific time of day, check the day and time inputif (timeSelection == 1) { if(!form.fwWebNotAnyday.checked && !form.fwWebSunday.checked && !form.fwWebMonday.checked && !form.fwWebTuesday.checked && !form.fwWebWednesday.checked && !form.fwWebThursday.checked && !form.fwWebFriday.checked && !form.fwWebSaturday.checked ) { alert("You must select a day!"); return false; } if ( !checkHour(form.fwWebHourStart) || !checkHour(form.fwWebHourEnd) || !checkMinute(form.fwWebMinuteStart) || !checkMinute(form.fwWebMinuteEnd) || !checkSecond(form.fwWebSecondStart) || !checkSecond(form.fwWebSecondEnd) ) return false; // compare time start and end value if ( parseInt(form.fwWebHourStart.value) > parseInt(form.fwWebHourEnd.value) ) { alert("Hour start greater than hour end, please re-enter"); return false; } else if ( parseInt(form.fwWebHourStart.value) == parseInt(form.fwWebHourEnd.value) && parseInt(form.fwWebMinuteStart.value) > parseInt(form.fwWebMinuteEnd.value) ) { alert("Minute start greater than minute end, please re-enter"); return false; } else if ( parseInt(form.fwWebHourStart.value) == parseInt(form.fwWebHourEnd.value) && parseInt(form.fwWebMinuteStart.value) == parseInt(form.fwWebMinuteEnd.value) && parseInt(form.fwWebSecondStart.value) > parseInt(form.fwWebSecondEnd.value) ) { alert("Second start greater than second end, please re-enter"); return false; } }// check fwWebAction selectionif (requireRadios (form, "fwWebActionDisplay", "Action") == -1) return false;// check log selectionif (requireRadios (form, "fwWebLogDisplay", "Log") == -1) return false; return true;}//check hour, munutes, secondsfunction checkInteger(element){//alert("checkInteger");if( !isInteger(element.value) || parseInt(element.value) < 0 ) { alert( "Please enter a integer greater than 0"); element.focus(); return false; }return true;}//check hour, munutes, secondsfunction checkHour(element){//alert("hour");if( !isInteger(element.value) || !inRange(element.value, 0, 23) ) { alert( "Please enter a number beween 0 and 23 for hour"); element.focus(); return false; }return true;}function checkMinute(element){//alert("minute");if( !isInteger(element.value) || !inRange(element.value, 0, 59) ) { alert( "Please enter a number beween 0 and 59 for minute"); element.focus(); return false; }return true;}function checkSecond(element){//alert("second");if( !isInteger(element.value) || !inRange(element.value, 0, 59) ) { alert( "Please enter a number beween 0 and 59 for Second"); element.focus(); return false; }return true;}function checkPort(element){//alert( "checkport");if( !isInteger(element.value) || !inRange(element.value, 0, 65535) ) { alert( "Please enter a number beween 0 and 65535 for port number!"); element.focus(); return false; }return true;}function CheckIPv6 (ip){return true;}function CheckIPv4 (ip){ var splitIP; splitIP = ip.split("."); // to check that there are dots between the numbers. if (splitIP.length == 1) return false; // to check that there are only 3 dots between the numbers. else if (splitIP.length != 4) return false; // to check that the each part of the ip has a length, i.e. no 2 dots after each other. else if ( (splitIP[0].length == 0) | (splitIP[1].length == 0) | (splitIP[2].length == 0) | (splitIP[3].length == 0) ) return false; // to check that each part has a length not greater than 3 digits. else if ( (splitIP[0].length > 3) | (splitIP[1].length > 3) | (splitIP[2].length > 3) | (splitIP[3].length > 3) ) return false; // to check on each part that it is integer only. else if ( !isInteger(splitIP[0]) | !isInteger(splitIP[1]) | !isInteger(splitIP[2]) | !isInteger(splitIP[3]) ) return false; // to check on each part that it is not excceeding 255. else if ( (splitIP[0] > 255) | (splitIP[1] > 255) | (splitIP[2] > 255) | (splitIP[3] > 255) ) return false; // to check on each part that it is not less than 0. else if ( (splitIP[0] < 0) | (splitIP[1] < 0) | (splitIP[2] < 0) | (splitIP[3] < 0) ) return false; // otherwise return true, that is IP is valid. else return true;}function CompareIP (ip1, ip2){form=document.forms['EditForm'];//alert("CompareIP !");if (form.fwWebDirection[2].checked || form.fwWebDirection[3].checked) {// alert ("CompareIP v6 addr"); return(CompareIPV6(ip1, ip2)); }else {// alert("CompareIP v4 addr!"); return (CompareIPV4 (ip1, ip2)); }// error case returnreturn 1;}function CompareIPV6 (ip1, ip2){return -1;}function CompareIPV4 (ip1, ip2){var splitIP1, splitIP2;splitIP1 = ip1.split(".");splitIP2 = ip2.split(".");// to check on each part that it is not excceeding 255.if ( parseInt(splitIP1[0]) > parseInt(splitIP2[0]) ) return 1; //addr1's first part is graterelse if ( parseInt(splitIP1[0]) == parseInt(splitIP2[0]) ) { if ( parseInt(splitIP1[1]) > parseInt(splitIP2[1]) ) return 1; //addr1's second part is greater else if ( parseInt(splitIP1[1]) == parseInt(splitIP2[1]) ) { if ( parseInt(splitIP1[2]) > parseInt(splitIP2[2]) ) return 1; //addr1's third part is greater else if ( parseInt(splitIP1[2]) == parseInt(splitIP2[2]) ) { if ( parseInt(splitIP1[3]) > parseInt(splitIP2[3]) ) return 1; //addr1's fourth part is greater else if ( parseInt(splitIP1[3]) == parseInt(splitIP2[3]) ) return 0; //addr1's all parts eaqual else return -1; //addr1's fourth part is less } else return -1; //addr1's third part is less } else return -1; //addr1's second part is less }else return -1; //addr1's first part is less}function checkReset(){enableTime();enablePort();return true;}function checkResetEdit(){form=document.forms['EditForm'];enableTime();enablePort();if (form.fwWebNotAnytime[0].checked) disableTime();else { if(form.fwWebNotAnyday.checked) disableDays(); }if (form.fwWebProtoDisplay[2].checked || form.fwWebProtoDisplay[3].checked) disablePort();return true;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -