Click here to Skip to main content
15,895,746 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Question"End of statement Expected" error Pin
samflex27-Feb-15 5:11
samflex27-Feb-15 5:11 
AnswerRe: "End of statement Expected" error Pin
PIEBALDconsult27-Feb-15 5:25
mvePIEBALDconsult27-Feb-15 5:25 
AnswerRe: "End of statement Expected" error Pin
Richard Deeming27-Feb-15 6:28
mveRichard Deeming27-Feb-15 6:28 
GeneralRe: "End of statement Expected" error Pin
samflex27-Feb-15 6:40
samflex27-Feb-15 6:40 
GeneralRe: "End of statement Expected" error Pin
Richard Deeming27-Feb-15 8:04
mveRichard Deeming27-Feb-15 8:04 
GeneralRe: "End of statement Expected" error Pin
samflex27-Feb-15 9:03
samflex27-Feb-15 9:03 
GeneralRe: "End of statement Expected" error Pin
Richard Deeming27-Feb-15 10:29
mveRichard Deeming27-Feb-15 10:29 
GeneralRe: "End of statement Expected" error Pin
samflex27-Feb-15 10:44
samflex27-Feb-15 10:44 
You are correct sir, my bad.

As stated, the code I posted there and the js version of it were created by you and they worked great.

The issue started when users of the app indicated that they would also like to warn users that there is a set fee for 4 hours use of their facility.

If they went over the 4 hour limit, there would additional fees.

As a result, I just managed, with some googling, to modify your script slightly to come up with the code below:
<script type="text/javascript">
              $(window).load(function () {
                  $("#txtFromDate").datepicker();
                  $('#timeStart').timepicker({ showPeriod: true,
                      onHourShow: OnHourShowCallback,
                      onMinuteShow: OnMinuteShowCallback
                  });

                  $("#txtToDate").datepicker();
                  $('#timeEnd').timepicker({ showPeriod: true,
                      onHourShow: OnHourShowCallback,
                      onMinuteShow: OnMinuteShowCallback
                  });
                  function OnHourShowCallback(hour) {
                      if ((hour > 20) || (hour < 6)) {
                          return false; // not valid
                      }
                      return true; // valid
                  }
                  function OnMinuteShowCallback(hour, minute) {
                      if ((hour == 20) && (minute >= 30)) { return false; } // not valid
                      if ((hour == 6) && (minute < 30)) { return false; }   // not valid
                      return true;  // valid
                  }
                  $('#btnSearch').on('click', function () {
                      var sDate = $("#txtFromDate").val();
                      var sTime = $("#timeStart").val();

                      var eDate = $("#txtToDate").val();
                      var eTime = $("#timeEnd").val();

                      var startDate = new Date(sDate + " " + sTime).getHours();
                      var endDate = new Date(eDate + " " + eTime).getHours();

                      //Calulate the time difference
                      var hourDiff = endDate - startDate;
                      //alert(hourDiff);

                      //Check if hour difference is less than 4 hours and show the message accordingly
                      if (hourDiff < 4) {
                          var r = false; $($("<div>A mininum of 4 hours is required!</div>")).dialog({ closeOnEscape: false, resizable: false, modal: true, open: function (event, ui) { $(".ui-dialog-titlebar-close").hide(); }, buttons: { Close: function () { r = false; $(this).dialog("close"); } }, close: function () { return r; } });
                          return false;
                      }

                      //Add the check condition if the user is above the 4 hours time frame
                      if (hourDiff > 4) {
                          var r = confirm("There may be additional fees for going over the 4 hours!");
                          if (r == true) { // pressed OK
                              return true;
                          } else { // pressed Cancel
                              return false;
                          }
                      }
                  });
              });
</script>


This code worked a treat.

However, the users said that if a user goes over the allocated 4 hours, then they need to know how many hours are over 4 hours and multiply that by the set overage fee of $89.00.

So when a user clicks the link, to be redirected to ReserveFacility.aspx, the total overage hours and associated fees must be passed to that page as well.

As it stands right now, you can't see the link until you click the btnSearch button.

So, the calculation has to be done after the hyperlink is visible and I struggled with this for so long that I just remembered there is vb version and that's the one I posted above.

If I can resolve the issue of ValidateDuration is undefined error that happens when I use it below:
PHP
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="endHour"
ErrorMessage="A minimum of four hours is required."
Text="*"
SetFocusOnError="True"
OnServerValidate="ValidateDuration"
ClientValidationFunction="ValidateDuration" />


then I will be glad to stay with the vb instead of the js. The js seems overly complicated for me.
GeneralRe: "End of statement Expected" error Pin
Richard Deeming2-Mar-15 1:43
mveRichard Deeming2-Mar-15 1:43 
GeneralRe: "End of statement Expected" error Pin
samflex2-Mar-15 4:04
samflex2-Mar-15 4:04 
GeneralRe: "End of statement Expected" error Pin
Richard Deeming2-Mar-15 7:10
mveRichard Deeming2-Mar-15 7:10 
GeneralRe: "End of statement Expected" error Pin
samflex2-Mar-15 14:55
samflex2-Mar-15 14:55 
QuestionJSON Hijacking and ASP.Net MVC Pin
Tridip Bhattacharjee27-Feb-15 1:55
professionalTridip Bhattacharjee27-Feb-15 1:55 
AnswerRe: JSON Hijacking and ASP.Net MVC Pin
Richard MacCutchan27-Feb-15 3:00
mveRichard MacCutchan27-Feb-15 3:00 
QuestionWeb site various attack and security Pin
Tridip Bhattacharjee26-Feb-15 23:55
professionalTridip Bhattacharjee26-Feb-15 23:55 
AnswerRe: Web site various attack and security Pin
Richard Deeming27-Feb-15 1:26
mveRichard Deeming27-Feb-15 1:26 
QuestionRe: Access from data from Ms access Pin
Praveen Kandari26-Feb-15 1:16
Praveen Kandari26-Feb-15 1:16 
AnswerRe: Access from data from Ms access Pin
Richard MacCutchan26-Feb-15 2:00
mveRichard MacCutchan26-Feb-15 2:00 
GeneralRe: Access from data from Ms access Pin
Praveen Kandari26-Feb-15 17:04
Praveen Kandari26-Feb-15 17:04 
Questionaccess data from ms access with date Pin
Praveen Kandari26-Feb-15 1:13
Praveen Kandari26-Feb-15 1:13 
SuggestionRe: access data from ms access with date Pin
ZurdoDev26-Feb-15 4:16
professionalZurdoDev26-Feb-15 4:16 
GeneralRe: access data from ms access with date Pin
Praveen Kandari26-Feb-15 17:06
Praveen Kandari26-Feb-15 17:06 
QuestionRe: access data from ms access with date Pin
ZurdoDev27-Feb-15 1:31
professionalZurdoDev27-Feb-15 1:31 
QuestionDelete files from server folders Pin
Sean_Vt25-Feb-15 8:36
Sean_Vt25-Feb-15 8:36 
AnswerRe: Delete files from server folders Pin
Afzaal Ahmad Zeeshan25-Feb-15 21:45
professionalAfzaal Ahmad Zeeshan25-Feb-15 21:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.