Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

checkdate function giving undefined error

Posted on 2003-11-03
30
479 Views
Last Modified: 2007-12-19
Hi!

I am calling the following javascript via the following two statements on an xsl page:

<td align="center">
            <input maxLength="8" name="startdt" size="8" onfocus="dosubmit=false;" onblur="dosubmit=checkDates();" value=""/>
           </td>
          <td align="center">
            <input maxLength="8" name="enddt" size="8" onfocus="dosubmit=false;" onblur="dosubmit=checkDates();" value=""/>
           </td>

I am getting the following error when I am leaving the start date field whether or not a value is entered:

startdt is undefined

Any ideas?

Chuck

 var dosubmit = true;

    function checkDates()
    {

          var sStartDate;
          var sEndDate;

           if (!checkDate(startdt)) return false;
           if (!checkDate(enddt)) return false;

          sStartDate = startdt.value;
          sEndDate = enddt.value;

           dtStartDate = ConvertStringToDate(startdt.value);
           dtEndDate = ConvertStringToDate(sEndDate);

           if (dtStartDate > dtEndDate)
           {
                alert('The end date (' + sEndDate + ') is earlier than the start date (' + sStartDate + ')');
                return false;
           }

           return true;

     }

     function ConvertStringToDate(sDate)
     {

          var sDateArray;
          var iMonth;
          var iDay;
          var iYear;

          if (sDate.indexOf('/') != -1)
           {
                sDateArray = sDate.split('/');
               iMonth = parseInt(sDateArray[0], 10);
               iDay = parseInt(sDateArray[1], 10);
               iYear = parseInt(sDateArray[2], 10);
           }

          return new Date(iYear, iMonth, iDay);

     }


   function checkDate(oDateElem, sDate)
   {


             var sDate = oDateElem.value;

             if (sDate.length < 1)
           {
                return true;
           }

           if (sDate.indexOf('/') != -1)
           {
                sDateArray = sDate.split('/');
                if (sDateArray.length != 3)
               {
                    alert('Invalid date (' + sDate + ').');
                    oDateElem.focus();
                    return false;
               }
                sMonth = sDateArray[0];
                sDay = sDateArray[1];
                sYear = sDateArray[2];
           }

           if (sYear.length == 1)
           {
                sYear = '200' + sYear;
           }
           if (sYear.length == 2)
           {
                sYear = '20' + sYear;
           }

           iDay = parseInt(sDay, 10);

           if (isNaN(iDay))
           {
               alert('Invalid date (' + sDate + ').');
               oDateElem.focus();
               return false;
           }

           iMonth = parseInt(sMonth, 10);
           if (isNaN(iMonth))
           {
               alert('Invalid date (' + sDate + ').');
               oDateElem.focus();
               return false;
           }

           iYear = parseInt(sYear, 10);
           if (isNaN(iYear))
           {
               alert('Invalid date (' + sDate + ').');
               oDateElem.focus();
               return false;
           }

           if (iYear < 1900 || iYear > 2078)
           {
               alert('Invalid date - year must be between 1900 and 2078 (' + sDate + ').');
               oDateElem.focus();
               return false;
           }


           if (iMonth > 12 || iMonth < 1)
           {
               alert('Invalid date - month must be between 1 and 12 (' + sDate + ').');
               oDateElem.focus();
               return false;
           }

           if ((iMonth == 1 || iMonth == 3 || iMonth == 5 || iMonth == 7 || iMonth == 8 || iMonth == 10 || iMonth == 12) && (iDay > 31 || iDay < 1))
           {
               alert('Invalid date - day must be between 1 and 31 (' + sDate + ').');
               oDateElem.focus();
               return false;
           }

           if ((iMonth == 4 || iMonth == 6 || iMonth == 9 || iMonth == 11) && (iDay > 30 || iDay < 1))
           {
               alert('Invalid date - day must be between 1 and 30 (' + sDate + ').');
               oDateElem.focus();
               return false;
           }

           if (iMonth == 2)
           {
                if (LeapYear(iYear) == true)
                {
                     if (iDay < 1 || iDay > 29)
                     {
                         alert('Invalid date - day must be between 1 and 29 (' + sDate + ').');
                         oDateElem.focus();
                         return false;
                     }
                }
                else
                {
                     if (iDay < 1 || iDay > 28)
                     {
                         alert('Invalid date - day must be between 1 and 28 (' + sDate + ').');
                         oDateElem.focus();
                         return false;
                     }
                }
           }

          oDateElem.value = iMonth + "/" + iDay + "/" + iYear;

           return true;
     }


     function LeapYear(iYear)
     {
          if (iYear % 100 == 0)
          {
               if (iYear % 400 == 0)
               {
                    return true;
               }
          }
          else
          {
               if ((iYear % 4) == 0)
               {
                    return true;
               }
          }
          return false;
     }
0
Comment
Question by:TrueBlue
  • 9
  • 8
  • 8
  • +2
30 Comments
 
LVL 5

Expert Comment

by:ho_alan
ID: 9676425
um...
1.u can use a form
<form name=fm1>
<td align="center">
           <input maxLength="8" name="startdt" size="8" onfocus="dosubmit=false;" onblur="dosubmit=checkDates();" value=""/>
          </td>
         <td align="center">
           <input maxLength="8" name="enddt" size="8" onfocus="dosubmit=false;" onblur="dosubmit=checkDates();" value=""/>
          </td>
</form>

then,  in the function
         sStartDate = document.fm1.startdt.value;
         sEndDate = document.fm1.enddt.value;
----------------------------------------------------------------------------------------
or

           <input maxLength="8" id="startdt" size="8" onfocus="dosubmit=false;" onblur="dosubmit=checkDates();" value=""/>
          </td>
         <td align="center">
           <input maxLength="8" id="enddt" size="8" onfocus="dosubmit=false;" onblur="dosubmit=checkDates();" value=""/>
          </td>

then,  in the function
         sStartDate = document.all.startdt.value;
         sEndDate = document.all.enddt.value;

hope this helps



0
 
LVL 5

Expert Comment

by:ho_alan
ID: 9676431
because "startdt"  is the name  of the input field
but a JS variable
0
 

Author Comment

by:TrueBlue
ID: 9676506
Hi ho_alan!

I used your second method, but unfortunately I get the exact same error.

If I understood correctly, you wanted me to substitue this:
 sStartDate = startdt.value;
 sEndDate = enddt.value;

with this:

 sStartDate = document.all.startdt.value;
 sEndDate = document.all.enddt.value;
 
Any other ideas?

Chuck
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 5

Expert Comment

by:ho_alan
ID: 9676551
um...u should  change

all  "startdt" and "enddt"
to be "document.all.startdt" and "document.all.enddt"

eg.
   if (!checkDate(document.all.startdt)) return false;
          if (!checkDate(document.all.enddt)) return false;

         sStartDate = document.all.startdt.value;
         sEndDate = document.all.enddt.value;

hope this  helps
0
 
LVL 5

Expert Comment

by:ho_alan
ID: 9676598
i have tried,should work  without error

<html>
<body>
<script>
var dosubmit = true;

   function checkDates()
   {

         var sStartDate= document.all.startdt;
         var sEndDate= document.all.enddt;

          if (!checkDate(sStartDate))  return false;
          if (!checkDate(sEndDate)) ; return false;


          dtStartDate = ConvertStringToDate(document.all.startdt.value);
          dtEndDate = ConvertStringToDate(sEndDate);

          if (dtStartDate > dtEndDate)
          {
               alert('The end date (' + sEndDate + ') is earlier than the start date (' + sStartDate + ')');
               return false;
          }

          return true;

    }

    function ConvertStringToDate(sDate)
    {

         var sDateArray;
         var iMonth;
         var iDay;
         var iYear;

         if (sDate.indexOf('/') != -1)
          {
               sDateArray = sDate.split('/');
              iMonth = parseInt(sDateArray[0], 10);
              iDay = parseInt(sDateArray[1], 10);
              iYear = parseInt(sDateArray[2], 10);
          }

         return new Date(iYear, iMonth, iDay);

    }


  function checkDate(oDateElem)
  {


            var sDate = oDateElem.value;

            if (sDate.length < 1)
          {
               return true;
          }

          if (sDate.indexOf('/') != -1)
          {
               sDateArray = sDate.split('/');
               if (sDateArray.length != 3)
              {
                   alert('Invalid date (' + sDate + ').');
                   oDateElem.focus();
                   return false;
              }
               sMonth = sDateArray[0];
               sDay = sDateArray[1];
               sYear = sDateArray[2];
          }

          if (sYear.length == 1)
          {
               sYear = '200' + sYear;
          }
          if (sYear.length == 2)
          {
               sYear = '20' + sYear;
          }

          iDay = parseInt(sDay, 10);

          if (isNaN(iDay))
          {
              alert('Invalid date (' + sDate + ').');
              oDateElem.focus();
              return false;
          }

          iMonth = parseInt(sMonth, 10);
          if (isNaN(iMonth))
          {
              alert('Invalid date (' + sDate + ').');
              oDateElem.focus();
              return false;
          }

          iYear = parseInt(sYear, 10);
          if (isNaN(iYear))
          {
              alert('Invalid date (' + sDate + ').');
              oDateElem.focus();
              return false;
          }

          if (iYear < 1900 || iYear > 2078)
          {
              alert('Invalid date - year must be between 1900 and 2078 (' + sDate + ').');
              oDateElem.focus();
              return false;
          }


          if (iMonth > 12 || iMonth < 1)
          {
              alert('Invalid date - month must be between 1 and 12 (' + sDate + ').');
              oDateElem.focus();
              return false;
          }

          if ((iMonth == 1 || iMonth == 3 || iMonth == 5 || iMonth == 7 || iMonth == 8 || iMonth == 10 || iMonth == 12) && (iDay > 31 || iDay < 1))
          {
              alert('Invalid date - day must be between 1 and 31 (' + sDate + ').');
              oDateElem.focus();
              return false;
          }

          if ((iMonth == 4 || iMonth == 6 || iMonth == 9 || iMonth == 11) && (iDay > 30 || iDay < 1))
          {
              alert('Invalid date - day must be between 1 and 30 (' + sDate + ').');
              oDateElem.focus();
              return false;
          }

          if (iMonth == 2)
          {
               if (LeapYear(iYear) == true)
               {
                    if (iDay < 1 || iDay > 29)
                    {
                        alert('Invalid date - day must be between 1 and 29 (' + sDate + ').');
                        oDateElem.focus();
                        return false;
                    }
               }
               else
               {
                    if (iDay < 1 || iDay > 28)
                    {
                        alert('Invalid date - day must be between 1 and 28 (' + sDate + ').');
                        oDateElem.focus();
                        return false;
                    }
               }
          }

         oDateElem.value = iMonth + "/" + iDay + "/" + iYear;

          return true;
    }


    function LeapYear(iYear)
    {
         if (iYear % 100 == 0)
         {
              if (iYear % 400 == 0)
              {
                   return true;
              }
         }
         else
         {
              if ((iYear % 4) == 0)
              {
                   return true;
              }
         }
         return false;
    }

</script>
<td align="center">
           <input maxLength="8" id="startdt" size="8" onfocus="dosubmit=false;" onblur="dosubmit=checkDates();" value=""/>
          </td>
         <td align="center">
           <input maxLength="8" id="enddt" size="8" onfocus="dosubmit=false;" onblur="dosubmit=checkDates();" value=""/>
          </td
</body>
</html>
0
 
LVL 5

Expert Comment

by:ho_alan
ID: 9676604
no ";",i mistyped it
         if (!checkDate(sEndDate))  return false;

please tell if u still have problems  :-)
0
 
LVL 5

Expert Comment

by:ho_alan
ID: 9676645
please wait
i am  making some changes for u

is that if user enters "1"
then it will be converted to "1/1/2000"?
0
 
LVL 5

Expert Comment

by:ho_alan
ID: 9676674
ok, i got it
please wait for my final version
0
 
LVL 5

Expert Comment

by:ho_alan
ID: 9676681
<html>
<body>
<script language=javascript>
var dosubmit = true;

   function checkDates()
   {

         var sStartDate= document.all.startdt;
         var sEndDate= document.all.enddt;

          if (!checkDate(sStartDate))  return false;
          if (!checkDate(sEndDate))  return false;


          dtStartDate = ConvertStringToDate(sStartDate.value);
          dtEndDate = ConvertStringToDate(sEndDate.value);

          if (dtStartDate > dtEndDate)
          {
               alert('The end date (' + sEndDate.value + ') is earlier than the start date (' + sStartDate.value + ')');
               return false;
          }

          return true;

    }

    function ConvertStringToDate(sDate)
    {

         var sDateArray;
         var iMonth;
         var iDay;
         var iYear;

         if (sDate.indexOf('/') != -1)
          {
               sDateArray = sDate.split('/');
              iMonth = parseInt(sDateArray[0],10);
              iDay = parseInt(sDateArray[1],10);
              iYear = parseInt(sDateArray[2],10);
          }

         return new Date(iYear, iMonth, iDay);

    }


  function checkDate(oDateElem)
  {

           var sDate = oDateElem.value;
         if (sDate == "") return true;
      
           if (sDate.length < 1)
      
          {
               return true;
          }

          if (sDate.indexOf('/') != -1)
          {
               sDateArray = sDate.split('/');
               sMonth = sDateArray[0];
               sDay = sDateArray[1];
               sYear = sDateArray[2];
          }
        else
        {
                alert('Invalid date (' + sDate + ').');
                oDateElem.focus();
                return false;
        }
         


          if (sYear.length == 1)
          {
               sYear = '200' + sYear;
          }
          if (sYear.length == 2)
          {
               sYear = '20' + sYear;
          }

          iDay = parseInt(sDay, 10);

          if (isNaN(iDay))
          {
              alert('Invalid date (' + sDate + ').');
              oDateElem.focus();
              return false;
          }

          iMonth = parseInt(sMonth, 10);
          if (isNaN(iMonth))
          {
              alert('Invalid date (' + sDate + ').');
              oDateElem.focus();
              return false;
          }

          iYear = parseInt(sYear, 10);
          if (isNaN(iYear))
          {
              alert('Invalid date (' + sDate + ').');
              oDateElem.focus();
              return false;
          }

          if (iYear < 1900 || iYear > 2078)
          {
              alert('Invalid date - year must be between 1900 and 2078 (' + sDate + ').');
              oDateElem.focus();
              return false;
          }


          if (iMonth > 12 || iMonth < 1)
          {
              alert('Invalid date - month must be between 1 and 12 (' + sDate + ').');
              oDateElem.focus();
              return false;
          }

          if ((iMonth == 1 || iMonth == 3 || iMonth == 5 || iMonth == 7 || iMonth == 8 || iMonth == 10 || iMonth == 12) && (iDay > 31 || iDay < 1))
          {
              alert('Invalid date - day must be between 1 and 31 (' + sDate + ').');
              oDateElem.focus();
              return false;
          }

          if ((iMonth == 4 || iMonth == 6 || iMonth == 9 || iMonth == 11) && (iDay > 30 || iDay < 1))
          {
              alert('Invalid date - day must be between 1 and 30 (' + sDate + ').');
              oDateElem.focus();
              return false;
          }

          if (iMonth == 2)
          {
               if (LeapYear(iYear) == true)
               {
                    if (iDay < 1 || iDay > 29)
                    {
                        alert('Invalid date - day must be between 1 and 29 (' + sDate + ').');
                        oDateElem.focus();
                        return false;
                    }
               }
               else
               {
                    if (iDay < 1 || iDay > 28)
                    {
                        alert('Invalid date - day must be between 1 and 28 (' + sDate + ').');
                        oDateElem.focus();
                        return false;
                    }
               }
          }

         oDateElem.value = iMonth + "/" + iDay + "/" + iYear;

          return true;
    }


    function LeapYear(iYear)
    {
         if (iYear % 100 == 0)
         {
              if (iYear % 400 == 0)
              {
                   return true;
              }
         }
         else
         {
              if ((iYear % 4) == 0)
              {
                   return true;
              }
         }
         return false;
    }

</script>
<td align="center">start
           <input maxLength="8" id="startdt" size="8" onfocus="dosubmit=false;" onblur="dosubmit=checkDates();" value=""/>
          </td>
         <td align="center">end
           <input maxLength="8" id="enddt" size="8" onfocus="dosubmit=false;" onblur="dosubmit=checkDates();" value=""/>
          </td>
</body>
</html>
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9677162
How about this:


<html>
<head>
<script>

 var dosubmit = true;

    function checkDates(theField)
    {
          var theForm = theField.form;
          var sStartDate;
          var sEndDate;

           if (!checkDate(theForm.startdt)) return false;
           if (!checkDate(theForm.enddt)) return false;

          sStartDate = theForm.startdt.value;
          sEndDate = theForm.enddt.value;

           dtStartDate = ConvertStringToDate(theForm.startdt.value);
           dtEndDate = ConvertStringToDate(sEndDate);

           if (dtStartDate > dtEndDate)
           {
                alert('The end date (' + sEndDate + ') is earlier than the start date (' + sStartDate + ')');
                return false;
           }

           return true;

     }

     function ConvertStringToDate(sDate)  {

          var sDateArray;
          var iMonth;
          var iDay;
          var iYear;

          if (sDate.indexOf('/') != -1)
           {
                sDateArray = sDate.split('/');
               iMonth = parseInt(sDateArray[0], 10);
               iDay = parseInt(sDateArray[1], 10);
               iYear = parseInt(sDateArray[2], 10);
           }

          return new Date(iYear, iMonth, iDay);

     }


   function checkDate(oDateElem)  {

     var sDate = oDateElem.value.split("/");
     if (sDate.length != 3) {
        return false;
     }
     iDate = new Date(oDateElem.value);
     iMonth = iDate.getMonth()+1;
     iDay = iDate.getDate();
     iYear = iDate.getFullYear();
     if(sDate[0]!=iMonth || sDate[1]!=iDay || sDate[2]!=iYear){
       alert('Invalid date.');
       oDateElem.select();
       oDateElem.focus();
       return false;
     }
     return true;
   }


</script>
</head>
<body>
<form>
<table><tr>
<td align="center">
            <input maxLength="10" name="startdt" size="10" onfocus="dosubmit=false;" onblur="dosubmit=checkDates(this);" value=""/>
           </td>
          <td align="center">
            <input maxLength="10" name="enddt" size="10" onfocus="dosubmit=false;" onblur="dosubmit=checkDates(this);" value=""/>
           </td>
</tr></table>
</form>
</body>
</html>



0
 

Expert Comment

by:ofeke
ID: 9677202
The problem might be that your function is located before the input field is created?

If so - try moving the function that deals with "strtdt" to the end of your code..
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 9677401
Please note that NetGrooves code will work in more browsers since it is passing the form/form field instead of usin IE only document.all
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 9677406
Ofeke: You can place the function anywhere as long as it is not CALLED before the form exists
0
 

Expert Comment

by:ofeke
ID: 9678298
Nope - some browsers perform "precheck" for objects. even IE do that in some cases.

Not only when you call a function - also when you cause an event, eval object etc etc
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 9678320
Not in my universe....
0
 

Author Comment

by:TrueBlue
ID: 9678801
Hi Ho_Alan!

I get the following error with the new version whether I enter a value or not.

Length is null or not an object

Chuck
0
 

Author Comment

by:TrueBlue
ID: 9678904
Hi Netgroove!

I get the same error length is null or not an object with your version as well.

Any ideas?

Chuck
0
 

Author Comment

by:TrueBlue
ID: 9678921
Hi Netgroove!

I was wrong I get value is null or not an object from your suggestion.

Thank you in advance.

Chuck
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9680255
Check this:

<html>
<head>
<script>
 var dosubmit = false;

    function checkDates(theField)
    {
          var theForm = theField.form;
          var sStartDate;
          var sEndDate;

           if (!checkDate(theForm.startdt)) return false;
           if (!checkDate(theForm.enddt)) return false;

          sStartDate = theForm.startdt.value;
          sEndDate = theForm.enddt.value;

           dtStartDate = ConvertStringToDate(theForm.startdt.value);
           dtEndDate = ConvertStringToDate(sEndDate);

           if (dtStartDate > dtEndDate)
           {
                alert('The end date (' + sEndDate + ') is earlier than the start date (' + sStartDate + ')');
                return false;
           }

           return true;

     }

     function ConvertStringToDate(sDate)  {

          var sDateArray;
          var iMonth;
          var iDay;
          var iYear;

          if (sDate.indexOf('/') != -1)
           {
                sDateArray = sDate.split('/');
               iMonth = parseInt(sDateArray[0], 10);
               iDay = parseInt(sDateArray[1], 10);
               iYear = parseInt(sDateArray[2], 10);
           }

          return new Date(iYear, iMonth, iDay);

     }


   function checkDate(oDateElem)  {

     var sDate = oDateElem.value.split("/");
     if (sDate.length != 3) {
        if(oDateElem.value>""){
          alert("Inavlid Date format: "+oDateElem.value+"\nEnter Date in this format: MM/DD/YYYY");
          oDateElem.select();
          oDateElem.focus();
        }
        return false;
     }
     iDate = new Date(oDateElem.value);
     iMonth = iDate.getMonth()+1;
     iDay = iDate.getDate();
     iYear = iDate.getFullYear();
     if(sDate[0]!=iMonth || sDate[1]!=iDay || sDate[2]!=iYear){
       alert('Invalid date.');
       oDateElem.select();
       oDateElem.focus();
       return false;
     }
     return true;
   }
</script>
</head>
<body>
<form onSubmit="return dosubmit">
<table><tr>
<td align="center">
            <input maxLength="10" name="startdt" size="10" onfocus="dosubmit=false;" onblur="dosubmit=checkDates(this);" value=""/>
           </td>
          <td align="center">
            <input maxLength="10" name="enddt" size="10" onfocus="dosubmit=false;" onblur="dosubmit=checkDates(this);" value=""/>
           </td>
</tr></table>
<input type=submit>
</form>
</body>
</html>


Also is your error message not comming from my example.
Some additional code contains some typo.
Could you post your complete code for debugging?

0
 

Author Comment

by:TrueBlue
ID: 9680943
Hi NetGroove!

I am sure the error is coming from this function because if I substitute:

       <input maxLength="10" name="enddt" size="10" onfocus="dosubmit=false;" onblur="dosubmit=checkDates(this);" value=""/>

with

       <input maxLength="10" name="enddt" size="10" value=""/>

I get no errors.

Here is my submission button in xslt:

  <xsl:if test="$aspemail != 'true'">
            <input type="submit" NAME="sendChanges" VALUE="Only Press Once to Send Changes">
              <xsl:attribute name="onclick"><![CDATA[ if(doSubmit) { document.form1.submit(); } ]]></xsl:attribute>
            </input>
          </xsl:if>

Here is my form code in asp:

<HTML>
  <head>
    <title>Call List Table</title>
   
     <script language="Javascript" type="text/javascript" src="datemask.js"></script>

  </head>
<body>
 <form name="form1" onsubmit="if(doSubmit) { return true; } else { return false; }" ACTION="calllist.asp" METHOD="POST">
   <input type="hidden" id="hiddeninput" value="">
   <input type="hidden" name="itemToDelete" value="">
   <input type="hidden" name=a value="<%=Request("a")%>">

Would I need to replace the phrase "theform" in your code with "form1" since that is what my form is named?

I did not include the opening / closing script tags when I copied this code to the datemask.js file.

Chuck
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9681289
The var dosubmit has to be global defined.
And the spelling has to be always the same, not doSubmit

You get an error for this event:
  onfocus="dosubmit=false;"

Because dosubmit is not previously defined.

In xslt you even name it doSubmit

Change all vars to same name.

0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9681322
Also the same for theForm. You can not rename it to theform or form1.
My proposal get the form reference trough the input field reference passed by reference to itself: this

0
 

Author Comment

by:TrueBlue
ID: 9681813
Hi NetGroove:

I did a search and replace through my asp, xsl and js pages. The variable is now doSubmit everywhere, but I am still get the same error value is null or not an object.

Is there a way to stop the script at certain points to see where the value problem is?

Similiar to response.write sStartdt
               response.end

Thank you for you help.

Chuck
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9682653
where is onSubmit origianly defined and initialized?
I supos it has to be defined in datemask.js

If it is nowhere initialized, then you get an error for compare in "if(doSubmit)"

0
 

Author Comment

by:TrueBlue
ID: 9683475
Hi NetGroove!

I have another javascript function that checks the telephone field's format.
It is initialized I believe in there.

var doSubmit = true;

It is called by a similiar statement on the xsl page as well.

<INPUT maxLength="12" name="priphone" size="12" onfocus="doSubmit=false;"
             onblur="checkPhone(this);" onkeyup="phoneMask(this);" onkeydown="phoneMask(this);"
             value=""/>

Chuck


0
 
LVL 5

Assisted Solution

by:ho_alan
ho_alan earned 250 total points
ID: 9684343
maybe u can add a function to check the invalid input first
because if the user doesn't enter properly
eg. he enters "1", then focus on the box
error will occur
0
 
LVL 10

Accepted Solution

by:
NetGroove earned 250 total points
ID: 9684423
init value should be: false

like:
var doSubmit = false;

Also it is possible to change your submit button to this:

  <xsl:if test="$aspemail != 'true'">
            <input type="submit" NAME="sendChanges" VALUE="Send Changes">
              <xsl:attribute name="onclick"><![CDATA[ if(doSubmit) {doSubmit=false; this.form.submit(); } ]]></xsl:attribute>
            </input>
          </xsl:if>

This button submits now the form only if changes have been approved after the last submit.

0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9755502
Please do not give grading B for such long running support.

Anyway, thanks for the points.
You do not know, but eperts get more points when you grade A.
If you want to do me a favor, then let correct your grading by posting a request in CS topic area:
http://www.experts-exchange.com/Community_Support/

Cheers,
NetGroove

0
 

Author Comment

by:TrueBlue
ID: 9755740
Hi NetGroove!

I appreciate your help on this issue, but I was never able to get it to work.

So I just closed the question.

Chuck
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9755764
Sorry for that.
Ok, hope next time to be of more help.

See you,
NetGroove

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question