ayuda con este codigo para jquery

editado agosto 2017 en Seguridad Web

alguien me puede ayudar con este codigo

var saveChk = false;
    jQuery( window ).load(function() {
        jQuery( "#primary-content" ).before( "<div class='MarLeft38 w650' id='passCodeError' style='display:none'><div class='errorMsg box MarTop10 Marbot10 MarLeftRight25'><p id='msgTxt'></p></div></div>" );
    });
    jQuery(document).ready(function() { 
        var errorChk = false;
        jQuery("#secondary-content").hide();
        jQuery("#wirelessnumber").blur(function(e){ 
        var numVal=jQuery("#wirelessnumber").val();
        var cTn = numVal.replace(/([\-\.\s\(\)])/g, '');
        if(cTn){
            if ((/^[0-9]+$/gi).test(cTn)){ 
                jQuery('#wirelessnumber').attr("value", cTn);
                jQuery("#wirelessNumberDiv").removeClass("error");
                jQuery("#errwirelessnumber").css('display','none');
            }
            else{
                jQuery("#wirelessNumberDiv").addClass("error");
                jQuery("#errNumerickwirelessNum").css('display','block'); 
            }
        }
        else{
            jQuery("#wirelessNumberDiv").addClass("error");
            jQuery("#errblankwirelessNum").css('display','block');   
        }
        jQuery("#wirelessNumberDiv span").removeClass("focus");
            validateForm();
        });         
        jQuery("#newpasscode").blur(function(e){ 
              var newPasscodeVal=jQuery("#newpasscode").val();
              var newPasscode = newPasscodeVal.replace(/([\-\.\s\(\)])/g, '');  
              var confirmPasscodeVal=jQuery("#confirmpasscode").val();
              var confirmPasscode = confirmPasscodeVal.replace(/([\-\.\s\(\)])/g, '');
              if(newPasscode){
              if ((/^[0-9]+$/gi).test(newPasscode) && (newPasscode.length >= 4) && (newPasscode.length <= 8)){
                  if(newPasscode == confirmPasscode){
                        jQuery("#confirmpasscodeDiv").removeClass("error");
                        jQuery("#errconfirmpasscode").css('display','none');
                        jQuery("#errblankconfirmpasscode").css('display','none');
                        jQuery("#errLengthConfirmpasscode").css('display','none');
                  }
                  jQuery('#newpasscode').attr("value", newPasscode);
                  jQuery("#newPasscodeDiv").removeClass("error");
                  jQuery("#errLengthnewpasscode").css('display','none');
            }
            else{
                jQuery("#newPasscodeDiv").addClass("error");
                jQuery("#errLengthnewpasscode").css('display','block');      
            }
            }else{
                jQuery("#newPasscodeDiv").addClass("error");
                jQuery("#errblanknewpasscode").css('display','block');  
            }
            jQuery("#newPasscodeDiv span").removeClass("focus");
            validateForm();
        });         
        jQuery("#confirmpasscode").blur(function(e){
            var newPasscode=jQuery("#newpasscode").val();   
            var confirmPasscodeVal=jQuery("#confirmpasscode").val();
            var confirmPasscode = confirmPasscodeVal.replace(/([\-\.\s\(\)])/g, '');
            if(confirmPasscode){
                if ((/^[0-9]+$/gi).test(confirmPasscode) && (confirmPasscode.length >= 4) && (confirmPasscode.length <= 8)){
                    if(newPasscode == confirmPasscode){
                        jQuery('#confirmpasscode').attr("value", newPasscode);
                        jQuery("#confirmpasscodeDiv").removeClass("error");
                        jQuery("#errconfirmpasscode").css('display','none');    
                    }else{
                        jQuery("#confirmpasscodeDiv").addClass("error");
                        jQuery("#errconfirmpasscode").css('display','block');
                    }
                }
                else{
                    jQuery("#confirmpasscodeDiv").addClass("error");
                    jQuery("#errLengthConfirmpasscode").css('display','block');      
                }
            }else{
                jQuery("#confirmpasscodeDiv").addClass("error");
                jQuery("#errblankconfirmpasscode").css('display','block'); 
            }
            jQuery("#confirmpasscodeDiv span").removeClass("focus");
            validateForm();
        });

        jQuery("#wirelessnumber").focus(function(e){
            jQuery("#wirelessNumberDiv").removeClass("error");
            jQuery("#errWirelessNumber").css('display','none');
            jQuery("#errblankwirelessNum").css('display','none');
            jQuery("#errNumerickwirelessNum").css('display','none');
        });     
        jQuery("#newpasscode").focus(function(e){
            jQuery("#newPasscodeDiv").removeClass("error");
            jQuery("#errblanknewpasscode").css('display','none');
            jQuery("#errLengthnewpasscode").css('display','none');
            jQuery("#errFwdSeqnewpasscode").css('display','none');
            jQuery("#errBckseqnewpasscode").css('display','none');
        });
        jQuery("#confirmpasscode").focus(function(e){
            jQuery("#confirmpasscodeDiv").removeClass("error");
            jQuery("#errconfirmpasscode").css('display','none');
            jQuery("#errblankconfirmpasscode").css('display','none');
            jQuery("#errLengthConfirmpasscode").css('display','none');
        });
        jQuery("#save").click(function(){
            saveChk = true;
        });
    });
    function savePasscode(){        
        jQuery('#backendErrorMsg').hide();
        jQuery('#passCodeError').hide();
        var newPasscodeVal=jQuery("#newpasscode").val();
        var newPasscode = newPasscodeVal.replace(/([\-\.\s\(\)])/g, '');
        var wirelessNumber=jQuery("#wirelessnumber").val();
        var confirmPasscode=jQuery("#confirmpasscode").val();
        var passcodeForwardSequenceTxt = jQuery('#passcodeForwardSequence').text();
        var passcodeReverseSequenceTxt = jQuery('#passcodeReverseSequence').text();
        var digitsNewPasscode = [];
        var tempNewPasscode = 0;
        var flagforward = 0;
        var flagreverse = 0;
        tempNewPasscode = newPasscode;            
        if(newPasscode){
            if ((/^[0-9]+$/gi).test(newPasscode) && (newPasscode.length >= 4) && (newPasscode.length <= 8)){               
                for (i = 0; i <= tempNewPasscode.length-1; i++) {                       
                    digitsNewPasscode.push(tempNewPasscode[i]);                     
                }                 
                for (i = 0; i <= digitsNewPasscode.length; i++) { 
                    if(parseInt(digitsNewPasscode[i+1]) == (parseInt(digitsNewPasscode[i])+1)){
                        flagforward = flagforward + 1;
                    }                             
                }
                for (i = 0; i <= digitsNewPasscode.length-1; i++) { 
                    if(parseInt(digitsNewPasscode[i]) == (parseInt(digitsNewPasscode[i+1])+1)){
                        flagreverse = flagreverse + 1;
                    }                             
                }
                if(flagforward==digitsNewPasscode.length-1){
                    jQuery('#passCodeError').show();
                    jQuery('#msgTxt').text(passcodeForwardSequenceTxt);
                    return false;
                }else if(flagreverse==digitsNewPasscode.length-1){
                    jQuery('#passCodeError').show();
                    jQuery('#msgTxt').text(passcodeReverseSequenceTxt);
                    return true;
                }else{
                    document.myForm.action="/olam/unauth/valTokenAndCreateAutoGenPassCode.myworld";
                    document.getElementByName("myForm").submit();
                }      
            }
        }
    }
    function validateForm(){
        var newPasscodeVal=jQuery("#newpasscode").val();
        var wirelessNumber=jQuery("#wirelessnumber").val();
        var confirmPasscode=jQuery("#confirmpasscode").val();
        if(saveChk == true){
            saveChk = true;
            var toSubmit = savePasscode();
            if(!toSubmit) {
                return true;
            }
        }
        if(!wirelessNumber || !newPasscodeVal || !confirmPasscode){
            document.getElementById("save").style.display="none";
            document.getElementById("saveDis").style.display="block";
        }else{
            document.getElementById("saveDis").style.display="none";
            document.getElementById("save").style.display="block";
        }       
    }

Comentarios

  • seria bueno que describieras que intentas hacer con el codigo y en que parte necesitas ayuda.

Accede o Regístrate para comentar.