test

function test(w){ var form = w ? '#form2' : '#form1'; var result = true; $(form + ' .field_need').each( function(){ var that = this; if($(this).val() == ''){ result = false; message(appdata.lang['digit_is_need'],'warning',function(){ $(that).get(0).focus(); $(that).get(0).select(); }); return false; } } ); var mask_regex = /^(0|128|192|224|240|248|252|254|255)$/; var tmp = "#"+ (w ? "w_" : "") + "mask_"; var first_mask = tmp + 1; var getPreVal = function(w){ }; $(form + ' input[name^=mask]').each(function(i){ flag = true; if(mask_regex.test($(this).val())){ //alert("pre_name:"+tmp + i+" pre_val:" + pre_val); if(i == 0){ if($(this).val() == 0){ flag = false; } }else{ var pre_val = $(tmp + i).val(); var next_val = (i pre_val){ flag = false; }else{ if($(this).val() != 0 && pre_val != 255){ flag = false; } } } }else{ flag = false; } if(!flag){ result = false; message(appdata.lang['subnet_mask_incorrect'],'warning',function(){ $(first_mask).focus(); $(first_mask).select(); }); return false; } }); return result; }

你可能感兴趣的:(test)