problem in validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madhuriks
    New Member
    • Jun 2010
    • 149

    problem in validation

    hi,
    in my project i need to do validation...my form is having some text fields..in that im doing validation...th e problem is it is validating for the 'NULL' in one text field and for the another it is not validating....m ay i know where is the problem..here is my code...

    login.js

    Code:
    if (document.frm.localAccNo.value == "")
        {
            alert("Enter Local A/c No. or 'NULL' in capitals");
            document.frm.localAccNo.focus();
            return (false);
        }
        var chkLocalAccNo = document.frm.localAccNo.value;
        //check if it is not a number
        var validation = true;
        if (isNaN(chkLocalAccNo))
        {
            //if it is not a number check if it is NULL
            if (chkLocalAccNo == 'NULL')
            {
                validation = true;
                document.frm.localAccNo.focus();
            }
            else
            {
                validation = false;
                document.frm.localAccNo.focus();
            }
        }
        return validation;    //Close of Local Units Status
    
        if (document.frm.localUnitValid.value == "")
        {
            alert("Enter Local Units Valid");
            document.frm.localUnitValid.focus();
            return (false);
        }//Close of Local Units Valid Status
    
        if (document.frm.localTrnsCode.value == "")
        {
            alert("Enter Local Units Transaction Code");
            document.frm.localTrnsCode.focus();
            return (false);
        }//Close of Local Units Transaction Code Status
    
        if (document.frm.stdAccNo.value == "")
        {
            alert("Enter STD A/c No. or 'NULL' in capitals");
            document.frm.stdAccNo.focus();
            return (false);
        }
        var chkStdAccNo = document.frm.stdAccNo.value;
        //check if it is not a number
        var validation1 = true;
        if (isNaN(chkStdAccNo))
        {
            //if it is not a number check if it is NULL
            if (chkStdAccNo == 'NULL')
            {
                validation1 = true;
                document.frm.stdAccNo.focus();
            }
            else
            {
                validation1 = false;
                document.frm.stdAccNo.focus();
            }
        }
        alert("Validation is :"+validation1);
        return validation1; //Close of STD A/c No. Status
    
        if (document.frm.stdUnits.value == "")
        {
            alert("Enter STD Units");
            document.frm.stdUnits.focus();
            return (false);
        }//Close of STD Units Status
    for 'localAccNo' it is validating and for 'stdAccNo' it is not validating...ma y i know where the code goes wrong
  • madhuriks
    New Member
    • Jun 2010
    • 149

    #2
    i got it...this question is closed..

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      line 25. you return from the function. any code after that cannot be processed.

      Comment

      Working...