Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Table created by loop in asp problem in doing validation through javascript


Message #1 by "arati palan" <aratipalan@h...> on Wed, 06 Feb 2002 13:15:17 +0000
Hello programers!

Help me out
Stuck up with Validation through javascript


I have created table in asp by using loop  it working nicely.

but while doing validation,
1.    the loop created in javascript for validation is checking the first 
row of table & then it comes out from the loop &

2.    the loop is checking the textbox and gives the message also but does 
not focus that text box it goes to the other textbox of the row.
i am giving the script here (its  bit long) please spare time & help



<script>
  function isempty(t)
  {
  if(t.value == "")
   return  true;
   else
   return false;
  }
  function checkIschar(z)
  {
  if (isNaN(z.value)== true)
   return 'y';
   else
      return 'n';
     }
  function checkform(form)
  {
     // if (checkfields(form)== true)
     //       document.f1.submit()
       //    else
      //  {
      // alert("please fill form correctly");
      //    document.f1.focus()
        //  }
   }
  function checkfields(f,b)
      {
      alert("f = " + f)
   var ff,element1,element2,element3,element4,element5,element6;
      alert("elements are created");
     for(ff = 1;ff >= f ; ff++);
            {
         alert ("FF = " + ff);
           element1 = eval('document.f1.name'+ ff);
        element2 = eval('document.f1.age' + ff);
        element3 = eval('document.f1.cmb' + ff);
        element4 = eval('document.f1.workingfield' + ff);
        element5 = eval('document.f1.emailadd' + ff);
        element6 = eval('document.f1.webadd' + ff);
         alert ("element1 = " + element1.value);
         alert ("element2 = " + element2.value);
         alert ("element3 = " + element3.value);
         alert ("element4 = " + element4.value);
         alert ("element5 = " + element5.value);
         alert ("element6 = " + element6.value);
       if (isempty(element1)==true)
          {
         alert("Please enter name");
         element1.focus()
          }
       else if(checkIschar(element1) == 'n')
          {
        alert("Please enter character only");
        element1.focus()
        element1.select()
          }
       else if (isempty(element2)==true)
         {
        alert("Please enter age");
        element2.focus()
         }
       else if(checkIschar(element2) == 'y')
         {
        alert("Please enter Numbers only");
        element2.focus()
        element2.select()
         }

       else if (element3.selectedIndex==0)
         {
        alert("Please Select persent activity");
          element3.focus();
         }
       else if (element3.selectedIndex==2)
          {
            if (isempty(element4)==true)
             alert ("pleaes enter working filed");
                element4.focus()
              if(checkIschar(element4) == 'n')
               {
              alert("pleaes enter only characters");
              element4.focus()
              element4.select()
                }
           }
        else if (isempty(element5)==true)
            {
            alert("Please enter Emial address");
            element5.focus()
             }
           /*else if(checkIsmail(element5) == 'n')
             {
            alert("Please enter valid mail address");
            element5.focus()
            element5.select()
             }*/
       else if (isempty(element6)==true)
           {
          alert("Please enter web address");
            element6.focus()
            }
       alert("hello from last line of loop ff = " + ff);
           /*else if(checkIsweb(element6) == 'n')
             {
            alert("Please enter valid web address");
            element6.focus()
            element6.select()
             }*/
       else if (ff ==> f)
       document.f1.submit();
        }
       alert("out of loop")
     }

</script>
regards
Arati





_________________________________________________________________
Join the world?s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


  Return to Index