Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript" language="javascript">
- function validate() {
- var elmnt_id;
- elmnt_id = document.getElementById('custom');
- if (elmnt_id.selected) {
- if (is_blank(document.form1.s_port_s)) {
- document.form1.s_port_s.focus();
- return fail("You must provide a starting port and (optionally) an ending one!");
- }
- else if (!is_valid_Port(document.form1.s_port_s.value)) {
- document.form1.s_port_s.focus();
- return fail("Ports are between 1 and 65535!");
- }
- else if (!is_blank(document.form1.s_port_e) && !is_valid_Port(document.form1.s_port_e.value)) {
- document.form1.s_port_e.focus();
- return fail("Ports are between 1 and 65535!");
- }
- else if (!is_blank(document.form1.s_port_e)) {
- var sport_s = parseInt(document.form1.s_port_s.value,10);
- var sport_e = parseInt(document.form1.s_port_e.value,10);
- if (sport_s > sport_e) {
- document.form1.s_port_s.focus();
- return fail("Start port values must be less or equal than ending port values!");
- }
- }
- }
- elmnt_id = document.getElementById('host_list');
- if (elmnt_id.selected) {
- if (is_blank(document.form1.in_host_list)) {
- document.form1.in_host_list.focus();
- return fail("You must provide a comma-separated list of remote hosts/IPs!");
- }
- //else {
- //var host_array = document.form1.in_host_list.value.split(",");
- //var host_id = 0;
- //while (host_id < host_array.length) {
- //alert(host_array[host_id]);
- //host_id += 1;
- //}
- //}
- }
- if (!is_valid_IP(document.form1.d_ip.value)) {
- document.form1.d_ip.focus();
- return fail("Invalid IP address!");
- }
- elmnt_id = document.getElementById('diff');
- return true;
- }
- function change_protocol(field) {
- switch ( field.value ) {
- case 'custom':
- document.form1.s_type.disabled = false;
- document.form1.s_port_s.disabled = false;
- document.form1.s_port_e.disabled = false;
- document.form1.s_type.value = 'both';
- document.form1.s_port_s.value = '';
- document.form1.s_port_e.value = '';
- set_visible('on_proto_port_1', 1);
- set_visible('on_proto_port_2', 1);
- set_visible('on_dest_port', 1);
- set_visible('off_dest_port', 0);
- document.form1.d_port.disabled = false;
- document.form1.d_port.value = '';
- break;
- default:
- document.form1.s_type.value = '';
- document.form1.s_port_s.value = '';
- document.form1.s_port_e.value = '';
- document.form1.s_type.disabled = true;
- document.form1.s_port_s.disabled = true;
- document.form1.s_port_e.disabled = true;
- set_visible('on_proto_port_1', 0);
- set_visible('on_proto_port_2', 0);
- set_visible('on_dest_port', 0);
- set_visible('off_dest_port', 1);
- elmnt_id = document.getElementById('same');
- elmnt_id.checked = true;
- document.form1.d_port.value = '';
- document.form1.d_port.disabled = true;
- break;
- }
- document.getElementById("same").checked = true;
- change_r_port(document.getElementById("same"));
- }
- function change_in_host(field) {
- switch ( field.value ) {
- case 'host_list':
- document.form1.in_host_list.disabled = false;
- break;
- default:
- document.form1.in_host_list.value = '';
- document.form1.in_host_list.disabled = true;
- break;
- }
- }
- function change_r_port(field) {
- if (field.value == 'same') {
- document.form1.d_port.disabled = true;
- }
- else {
- document.form1.d_port.disabled = false;
- }
- return true;
- }
- function change_multiple(field) {
- if (field && field.value != '') {
- set_visible('on_dest_port', 0);
- } else {
- set_visible('on_dest_port', 1);
- }
- }
- function init() {
- var elmnt_id;
- if (elmnt_id = document.getElementById("")) {
- elmnt_id.selected = true;
- }
- if (elmnt_id = document.getElementById("custom")) {
- elmnt_id.selected = true;
- }
- change_protocol(document.form1.protocol);
- if ("custom" == 'custom') {
- document.form1.s_type.value = "both";
- document.form1.s_port_s.value = "";
- document.form1.s_port_e.value = "";
- }
- if (elmnt_id = document.getElementById("host_all")) {
- elmnt_id.selected = true;
- }
- change_in_host(document.form1.in_host);
- document.form1.d_ip.value = "";
- document.form1.in_host_list.value = "";
- if (elmnt_id = document.getElementById("same")) {
- elmnt_id.checked = true;
- change_r_port(elmnt_id);
- }
- document.form1.d_port.value = "";
- if (document.getElementById('s_port_s').value != '') {
- change_multiple(document.getElementById('s_port_e'));
- }
- return true;
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement