|
Greetings Experts,
I have the following javascript:
<script type="text/javascript">
$(document).ready(function () {
$(
buttonImage:
buttonImageOnly: true, onSelect: function (dateText, inst) {
//Calculate the days here
var days = ($("#txtToDate").datepicker(
//Assign it to textbox
$(
},
onClose: function () { $(this).focus(); }
});
$(
buttonImage:
buttonImageOnly: true, onSelect:
function (dateText, inst) {
$(
}
,
onClose: function () { $(this).focus(); }
});
});
</script>
<script type='text/javascript'>//<![CDATA[
$(window).load(function () {
//Attach click event to button
$(
//Get Values from dropdownlist
var sHour = $(
eHour = $(
//create date format from dropdownlist selected values
var timeStart = new Date(txtFromDate + sHour).getHours();
var timeEnd = new Date(txtToDate + eHour).getHours();
//Calulate the time difference
var hourDiff = timeEnd - timeStart;
//Check if hour difference is less than or equal to 2 hours and show the message accordingly
if (hourDiff <= 2) {
alert("A mininum of 2 hours per reservation is required!");
}
});
});//]]>
</script>
<asp:TextBox ID="txtFromDate" class="fptextbox12" placeholder="MM/DD/YYYY" runat="server" style="width:160px;"></asp:TextBox>
<asp:TextBox ID="txtToDate" class="fptextbox12" placeholder="MM/DD/YYYY" runat="server" style="width:160px;"></asp:TextBox>
The top part of Javascript is used for our datepicker functionality.
A user selects a startdate and an enddate and the total number of days between the startdate and enddate are stored in a control ID called numOfDays.
This works fine.
The second part of the javascript is where I am having issues.
A user selects start time and end time.
If the difference between starttime and endtime is not up to atleast 2 hours, the user is notified that a minimum of two hours is required.
The issue is that I am trying to store the value of startDate and endDate in the two lines below and append time to them but this not working:
var timeStart = new Date(txtFromDate + sHour).getHours();
var timeEnd = new Date(txtToDate + eHour).getHours();
Any ideas what I am doing wrong?
|
|
|
|
|
Hi, samflex, you check if the values
var timeStart = new Date(txtFromDate + sHour).getHours();
var timeEnd = new Date(txtToDate + eHour).getHours();
have the correct value?? Futhermore you need be carefully with the behavior of dropdownlist
Regarts
|
|
|
|
|
Hi Pablo,
Thanks for the prompt response.
What you just posted is what I have though. What am I missing?
Just to explain further, when you select a date value from the datepicker, say for instance, the FromDate, it goes into the control below:
<asp:TextBox ID="txtToDate" class="fptextbox12" placeholder="MM/DD/YYYY" runat="server" style="width:160px;"></asp:TextBox>
What I am trying to do is grab that value and stick it into this:
var timeStart = new Date(txtFromDate + sHour).getHours()
This way, if I select start time of 12:00PM, it should show something like:
06/24/2014 12:00PM.
Same goes with txtToDate. Am I not doing it correctly?
|
|
|
|
|
Hi Samflex, probably you need to use other method to obtain the correct time. JS have a little tricks with the dates and it is a little confused.
Is better than you check this page
http://www.w3schools.com/js/js_dates.asp[^]
that have a lot of information about that.
With the few details that I can see, me mainly suppose that your problem is the format. So please check the page for more information
Regarts.
PD: If need more help, feel free to ask.
|
|
|
|
|
|
In GridView, one column is of checkboxes, I need that if any duplicate record is there for e.g. Name is duplicate and we check its checkbox then record of its duplicate name should also get checked.
|
|
|
|
|
Hi,
Lets assume that you want to do on Name so if check one checkbox with Name Ravi and there are 3 record with Name Ravi then all 3 checkbox should get checked,
so you can do like below, lets say that you are having checkboxes
<div id="mainGridDiv">
<input type="checkbox" value="<Name>"/>
<input type="checkbox" value="<Name>"/>
<input type="checkbox" value="<Name>"/>
</div>
JQuery Code
$("#mainGridDiv input[type=checkbox]").change(function(){
var currValue = $(this).val();
$("#mainGridDiv input[type=checkbox]").find("[value='"+currValue+"']").attr("checked",$(this).checked)
});
NOTE:Assuming checkbox is one column of your grid.
Thanks
Raviranjan
|
|
|
|
|
Hello,
I am using regex to validate some patterns in javascript
My pattern is
[VF][0-9]
And required output is V1-V9 , F1-F9 in any order (eg:V1,V3,V2,F1,F5,F3) OR (eg: F1,F5,F3,V1,V3,V2)
But it is not working can any one help me?
Thanks and regards.
|
|
|
|
|
You question is not clear. The regex provided will check if the string has an V or F (case sensitive) at the first position and then a digit (0-9).
But the part of the 'required output' is confusing! What the input, what the output, what have you expected?
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Hello,
My input is something like V1V2-V3-S-V4-F1
And I need to validate the given value contain any of V1 to V9 or F1 to F9 and S.
eg: if user input V20V30-V12-S10-V20-F10 I have to show a error because only 1-9 is allowed.
eg2: if user input R1R2-R3-S-R5-T6 I have to show a error because only V,S,F allowed
And it is not mandatory to enter V/F but S is mandatory.
I think it is clear now.
|
|
|
|
|
|
You need the pattern "[VF][1-9]-?$"
Because V20 matchs [VF][1-9] as V2
Hope this will help you.
|
|
|
|
|
when i use this code it doesnt work correctly :
<script type="text/javascript" src="includes/mootools.js"></script>
<script type="text/javascript" src="includes/ja_contentslide.js"></script>
<script>
jQuery.noConflict();
//(function( $ ) {
// Your jQuery code here, using the $
//})( jQuery );
</script>
<script type="text/javascript" src="slidshow/modernizr.js"></script>
<script type="text/javascript" src="slidshow/jquery_004.js"></script>
<script type="text/javascript" src="slidshow/jquery_006.js"></script>
|
|
|
|
|
Member 9473809 wrote: doesnt work correctly It's a bit confusing. What does not work? There is an error? No error but the outcome is different from what you have expected?
In any way - from the piece of code here it seems that you use jQuery before including it!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
function GetEqrDataUploadFiles()
{
var upload=$("#files").data("KendoUpload");
var s = upload.wrapper[0].childNodes[2].childNodes.length;
var a = new Array();
for (i = 0; i < s; i++)
{
if (document.all) {
a.push(upload.wrapper[0].childNodes[2].childNodes[i].innerText);
}
else {
a.push(upload.wrapper[0].childNodes[2].childNodes[i].textContent);
}
}
return a;
}
|
|
|
|
|
This means that upload.wrapper[0] is null. You'll need to debug it to figure out why.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
javascript Run Time Error[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Hi,
From where you are calling function GetEqrDataUploadFiles(), can you try to call function GetEqrDataUploadFiles() from inside document.ready function if you are not?
Thanks
Raviranjan
|
|
|
|
|
check the result of the follow code:
alert(upload.wrapper && upload.wrapper.length);
|
|
|
|
|
Hi,
I am new to javascript. How to increment the margin left value using javascript while mouseover time.
NalluJi
|
|
|
|
|
|
In what way is a switch more efficient than an if statment?
|
|
|
|
|
1. If your "if" condition is based on a single condition and single value.
2. If there is multiple "else if" conditions exists.
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /
|
|
|
|
|
If your condition has multiple if else statements then you should use if, if you can. For example,
if(ch == 'a')
{
...
...
}
else if(ch == 'b')
{
...
...
}
else if(ch == 'c')
{
...
...
}
is equivalent to
switch(ch)
{
case 'a':
......
...... break;
case 'b':
......
...... break;
case 'c':
......
...... break;
}
|
|
|
|
|
In if conditions you have to give the variable every time and while in switch case , you just have to define cases no need to give variable name every time...
|
|
|
|