how to print all messages in a single alert box.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • narinas
    New Member
    • Jan 2012
    • 20

    how to print all messages in a single alert box.

    this is my validation code & i want to print all error msg's in single alert box.
    please can any one send me the code 4 that
    Code:
    function validate_grid(value,id,ind)
    {
    var err_str="";
    if(ind==1 || ind==2)
    {
    var patt=/^([0-9]|[0][0-9]|[1][0-9]|[2][0-3])[:\.]{1} [0-5][0-9]$/;
    if(!patt.test(value))
    {
    mygrid.setCellTextStyle(id,ind,"background-color:yellow;");
    if(err_str!="")
    err_str+="\n"+(ind+1)+". Enter numbers and : only";
    else
    err_str=(ind+1)+".Enter numbers and : only";
    alert(err_str);
    return false;
    }
    else
    {
    mygrid.setCellTextStyle(id,ind,"background-color:white;");
    return true;
    alert(err_str);
    }
    }
    else if(ind==3 || ind==4)
    {
    var patt=/^[0-9]+[\.]?[0-9]{0,2}$/;
    if(!patt.test(value))
    { mygrid.setCellTextStyle(id,ind,"background-color:yellow;");
    if(err_str!="")
    err_str+="\n"+(ind+1)+". Enter floating type values only........";
    else
    err_str=(ind+1)+".Enter floating type values only........";
    alert(err_str);
    return false;
    }
    else
    {
    mygrid.setCellTextStyle(id,ind,"background-color:white;");
    return true;
    alert(err_str);
    }
    }
    else if(ind==6)
    {
    var patt=/^[0-9]{2}[\-][a-z]{3}[\-][0-9]{4}$/i;
    if(!patt.test(value))
    {
    mygrid.setCellTextStyle(id,ind,"background-color:yellow;");
    if(err_str!="")
    err_str+="\n"+(ind+1)+".Enter Date";
    else
    err_str=(ind+1)+".Please enter Date";
    alert(err_str);
    return false;
    }
    else
    {
    mygrid.setCellTextStyle(id,ind,"background-color:white;");
    return true;
    alert(err_str);
    }
    }
    }
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    alert err_str at the end of the function

    PS. /^(\d|[01]\d|2[0-3])[:.] [0-5]\d$/
    Last edited by Dormilich; Jan 13 '12, 12:40 PM.

    Comment

    • narinas
      New Member
      • Jan 2012
      • 20

      #3
      no im not getting it

      Comment

      • javaranjith
        New Member
        • Dec 2011
        • 1

        #4
        Instead of using this code (alert(err_str) ;) in all loop, move this at the end of the function.

        Comment

        • narinas
          New Member
          • Jan 2012
          • 20

          #5
          i did it but is showing alert as undefined.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            if there is no error (hence no error string) you must not use alert().

            Comment

            • narinas
              New Member
              • Jan 2012
              • 20

              #7
              il get error msg when the validation is false so if all the indexes get errors error msg will display & i need all the msg's to be displayed in a single alert box.

              Comment

              Working...