submitting form

Results 1 to 2 of 2

Thread: submitting form

  1. #1
    Join Date
    Dec 1969

    Default submitting form

    Hi friends, I have this function which I am calling..There is a problem when the dates are invalid its displaying the alert box but not proceeding fromt there <BR><BR>function validateDates(d1,d2){<BR> <BR> if (d1 != ""){<BR> date1 = formDate(d1);<BR> if (!date1)<BR> return false;<BR> }<BR> if (d2 != ""){<BR> date2 = formDate(d2);<BR> if(!date2)<BR> return false;<BR> }<BR> <BR> <BR> if (d1 != "" && d2 != "")<BR> {<BR> var difference = date2 - date1;<BR> var tt=0<BR> //alert(difference)<BR> if (difference &#062; 0 )<BR> {<BR> tt=1<BR> alert("Date of Completion cannot be Prior to Current Date");<BR> //alert("From Date cannot be greater than the To Date");<BR> //alert(" Date Out cannot be greater than Due Date");<BR> return false;<BR> }<BR> }<BR> <BR> }<BR><BR>function SQsave(obj)<BR>{<BR>if(isEmpty(obj.PROJECT_COMP_DA TE.value))<BR> {<BR> alert("Please enter Project Commence Date");<BR> obj.PROJECT_COMP_DATE.focus()<BR> return false;<BR> }<BR> <BR> <BR> var sdate=obj.PROJECT_COMP_DATE.value<BR> var endate=obj.edate.value<BR> <BR> if(validateDates(sdate,endate))<BR> {<BR> return false<BR> }<BR> <BR> <BR> <BR> if(confirm("Are you sure!"))<BR> { <BR> obj.action="xt_newproject.asp?from=save"<BR> obj.submit()<BR> } <BR> <BR>}<BR><BR><BR>&#060;input type="hidden" name="edate" value="&#060;%=now()%&#062;"&#062;<BR>&#060;input type="image" src="../images/save.gif" onClick="SQsave(this.form)"&#062;

  2. #2
    Join Date
    Dec 1969

    Default Missing ONE CHARACTER!

    The exclamation point!<BR><BR> if([hl="yellow"] ! [/hl]validateDates(sdate,endate) )<BR> {<BR> return false;<BR> }<BR><BR>THINK about what you wrote! You wrote "if the dates are valid then quit right now by returning false". You want it the other way around!<BR><BR>Also, you really should *ALWAYS* return a value from a function. Your validateDates() function returns nothing at all if the dates are okay. You should have a<BR> return true;<BR>just before the last } of that function.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts