[RESOLVED]issue with function

hi,

   i have a javascript function where i added for date validations for my frontend paramters and i also added another method loadfile(); which will redirect to another page.

But my question is where to place new method in validate function because after all the  validations we have to call new method .load file…

if you dont enter froma nd to dates and if user clicks on submit button it has to show message before that it was able to but after i added loadfile method..not sure how to put in right condition…pls guide me

aspx page

<asp:Button
ID="btnSubmit"
runat="server"
Text="Submit"
OnClientClick="return
validate();"
/>

Validate function–

  function validate() {
            loadfile();
            var summary = "";
            summary += isvaliddate();
            summary += isvalidDatefrom();
            summary += isvalidDateto();
            if (summary != "") {
                alert(summary);
                return false;
            }
            else {
                return true;
            }
        }
        
        function lLoadFile() {

            var fromDate = $find("<%= rdtpDateFrom.ClientID %>").get_selectedDate().toLocaleDateString("en-US");
            //Get the Datepickeer2
            var toDate = $find("<%= rdtpDateTo.ClientID %>").get_selectedDate().toLocaleDateString("en-US");
            var features = "left=100,top=100,height=1110,width=1440,status=no,resizable=yes,toolbar=no,menubar=no,location=no";
            window.open("../load_hhk.aspx?fDate=" + fromDate + "&tDate=" + toDate, "_blank", features, false);

        }
       
        function isvaliddate() {
            var RadTimePicker1 = $find("<%= rdtpDateFrom.ClientID %>");
            //Get the Datepickeer2
            var RadTimePicker2 = $find("<%= rdtpDateTo.ClientID %>");
            //Get the selected values
            var Date1 = new Date(RadTimePicker1.get_selectedDate());
            var Date2 = new Date(RadTimePicker2.get_selectedDate());
            //Check if Datel is less than Date2
            if ((Date2 - Date1) < 0) {
                //if so then show the message
                return("From-date should be 'less' than to-date & to-date should be 'greater' than from-date");
            }
            else {
                return "";
            }
        }

        function isvalidDatefrom() {
            var uid;
            var temp = document.getElementById("<%=rdtpDateFrom.ClientID %>");
            uid = temp.value;
            if (uid == "") {
                return ("Please enter Appeal Date-From" + "n");
            }
            else {
                return "";
            }
        }

        function isvalidDateto() {
            var uid;
            var temp = document.getElementById("<%=rdtpDateTo.ClientID %>");
            uid = temp.value;
            if (uid == "") {
                return ("Please enter Appeal Date-To" + "n");
            }
            else {
                return "";
            }
        }

function validate() {
            
            var summary = "";
            summary += isvaliddate();
            summary += isvalidDatefrom();
            summary += isvalidDateto();
            if (summary != "") {
                alert(summary);
            }
            else {
                loadfile();
            }
        }

This should do … 

Hi mcfarlanparkway,

Based on my understanding,it seems that you want to call the new method after all the validation works.if not, just return false for current page.

You can try the code below:

function validate(){
   var summary = "";
            summary
+= isvaliddate();
            summary
+= isvalidDatefrom();
            summary
+= isvalidDateto();
           
if (summary != "") {
alert(summary);
               
return false;
           
}
else{ loadfile(); } }

Best Regards,

Kevin Shen.

Leave a Reply