+function portValidator (port_str){
+ if (port_str != ""){
+ var port_validator=/^([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/;
+ var result = port_str.match(port_validator);
+ if (result==null){
+ return false;
+ }
+ else{
+ return true;
+ }
+ }
+ else {
+ return true;
+ }
+}
+
+function ipProtoValidator (ipproto_str){
+ if (ipproto_str != ""){
+ var ipproto_validator=/(^[0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5]$)/;
+ var result = ipproto_str.match(ipproto_validator);
+ if (result==null){
+ return false;
+ }
+ else{
+ return true;
+ }
+ }
+ else {
+ return true;
+ }
+}
+
+function wavelengthValidator (wavelength_str){
+ var wavelength_validator=/^\d+.?\d*$/;
+ var result = wavelength_str.match(wavelength_validator);
+ if (result==null){
+ return false;
+ }
+ else{
+ return true;
+ }
+}
+
+
+
+
+
+
+
+
+function validateFvfForm(){
+ var status = false;
+ var checked =0;
+
+ //row 1 validation
+ if (macValidator ($("#uob_fv_table_dl_src_start").val())==false){
+ $("#uob_fv_table_dl_src_start").addClass('error');
+ $("#uob_fv_table_dl_src_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ if (macValidator ($("#uob_fv_table_dl_src_end").val())==false){
+ $("#uob_fv_table_dl_src_end").addClass('error');
+ $("#uob_fv_table_dl_src_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ //row 2 validation
+
+ if (macValidator ($("#uob_fv_table_dl_dst_start").val())==false){
+ $("#uob_fv_table_dl_dst_start").addClass('error');
+ $("#uob_fv_table_dl_dst_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ if (macValidator ($("#uob_fv_table_dl_dst_end").val())==false){
+ $("#uob_fv_table_dl_dst_end").addClass('error');
+ $("#uob_fv_table_dl_dst_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ //row 3 validation
+
+ if (ethertypeValidator ($("#uob_fv_table_dl_type_start").val())==false){
+ $("#uob_fv_table_dl_type_start").addClass('error');
+ $("#uob_fv_table_dl_type_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ if (ethertypeValidator ($("#uob_fv_table_dl_type_end").val())==false){
+ $("#uob_fv_table_dl_type_end").addClass('error');
+ $("#uob_fv_table_dl_type_error").show();
+ }
+ else {
+ checked++;
+ }
+
+
+ //row 4 validation
+ if (vlanValidator ($("#uob_fv_table_vlan_id_start").val())==false){
+ $("#uob_fv_table_vlan_id_start").addClass('error');
+ $("#uob_fv_table_vlan_id_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ if (vlanValidator ($("#uob_fv_table_vlan_id_end").val())==false){
+ $("#uob_fv_table_vlan_id_end").addClass('error');
+ $("#uob_fv_table_vlan_id_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ //row 5 validation
+ if (ipValidator ($("#uob_fv_table_nw_src_start").val())==false){
+ $("#uob_fv_table_nw_src_start").addClass('error');
+ $("#uob_fv_table_nw_src_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ if (ipValidator ($("#uob_fv_table_nw_src_end").val())==false){
+ $("#uob_fv_table_nw_src_end").addClass('error');
+ $("#uob_fv_table_nw_src_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ //row 6 validation
+ if (ipValidator ($("#uob_fv_table_nw_dst_start").val())==false){
+ $("#uob_fv_table_nw_dst_start").addClass('error');
+ $("#uob_fv_table_nw_dst_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ if (ipValidator ($("#uob_fv_table_nw_dst_end").val())==false){
+ $("#uob_fv_table_nw_dst_end").addClass('error');
+ $("#uob_fv_table_nw_dst_error").show();
+ }
+ else {
+ checked++;
+ }
+
+
+
+ //row 7 validation
+
+ if (ipProtoValidator ($("#uob_fv_table_nw_proto_start").val())==false){
+ $("#uob_fv_table_nw_proto_start").addClass('error');
+ $("#uob_fv_table_nw_proto_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ if (ipProtoValidator ($("#uob_fv_table_nw_proto_end").val())==false){
+ $("#uob_fv_table_nw_proto_end").addClass('error');
+ $("#uob_fv_table_nw_proto_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ //row 8 validation
+ if (portValidator ($("#uob_fv_table_tp_src_start").val())==false){
+ $("#uob_fv_table_tp_src_start").addClass('error');
+ $("#uob_fv_table_tp_src_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ if (portValidator ($("#uob_fv_table_tp_src_end").val())==false){
+ $("#uob_fv_table_tp_src_end").addClass('error');
+ $("#uob_fv_table_tp_src_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ //row 9 validation
+ if (portValidator ($("#uob_fv_table_tp_dst_start").val())==false){
+ $("#uob_fv_table_tp_dst_start").addClass('error');
+ $("#uob_fv_table_tp_dst_error").show();
+ }
+ else {
+ checked++;
+ }
+
+ if (portValidator ($("#uob_fv_table_tp_dst_end").val())==false){
+ $("#uob_fv_table_tp_dst_end").addClass('error');
+ $("#uob_fv_table_tp_dst_error").show();
+ }
+ else {
+ checked++;
+ }/**/
+
+ //validate that at least one port is selected
+ var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+ var nodes = $('input',port_table.fnGetNodes());
+
+ var port_selected=false;
+ for(var i=0;i<nodes.length;i++){
+ if(nodes[i].checked==true){
+ checked++;
+ port_selected=true;
+ break;
+ }
+ }
+
+ if (checked >= 19) {
+ status=true;
+ }
+
+ if (port_selected==false & checked == 18){
+ alert("you need to select at least one port");
+ }
+ else if (port_selected==false & checked <= 18){
+ alert("you need to select at least one port and correct other flowspace parameter errors");
+ }
+ else if (port_selected==true & checked <= 18){
+ alert("you need to correct other flowspace parameter errors");
+ }
+
+ //alert("validator status:"+status+" checked:"+checked);
+ return status;
+}
+
+function validateoFvfForm(){
+ var status = false;
+ var checked =0;
+
+ //row 1 validation
+ if (wavelengthValidator($('#uob_ofv_table_wavelength').val())==false){
+ $("#uob_ofv_table_wavelength").addClass('error');
+ $("#uob_ofv_table_wavelength_error").show();
+ }
+ else {
+ checked++;
+ }
+
+
+
+ //validate that at least one port is selected
+ var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+ var nodes = $('input',port_table.fnGetNodes());
+
+ var port_selected=false;
+ for(var i=0;i<nodes.length;i++){
+ if(nodes[i].checked==true){
+ checked++;
+ port_selected=true;
+ break;
+ }
+ }
+
+ if (checked >= 2) {
+ status=true;
+ }
+
+ if (port_selected==false & checked == 1){
+ alert("you need to select at least one port");
+ }
+ else if (port_selected==false & checked <= 1){
+ alert("you need to select at least one port and correct other flowspace parameter errors");
+ }
+ else if (port_selected==true & checked <= 1){
+ alert("you need to correct other flowspace parameter errors");
+ }
+
+ //alert("validator status:"+status+" checked:"+checked);
+ return status;
+}
+
+