本文介绍了在javascript中将字符串与日期时间进行比较时出现问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function TimeSpentForFutureDate() {
                var toDate = new Date();
                toDate.setMinutes(0);
                toDate.setSeconds(0);
                toDate.setHours(0);
                toDate.setMilliseconds(0);
//Here after selecting future date also, this condition is failing.The textbox containing future date
                if (document.getElementById('<%= txtDate.ClientID%>').value > toDate) {
                    var timespent = jPrompt('Enter Time Spent:', '', 'Enter Time Spent', function (r) {
                        if (r) {
                            document.getElementById('<%= hiddenFieldFutureDateSelectTimeSpent.ClientID%>').value = r;
                            jAlert('You entered ' + r);
                        }
                        else {
                            var todaysDate = new Date();
                            jAlert('You had not entered the Time Spent', 'Message');
                        }
                    });
                }
                else {
                    document.getElementById('<%= hiddenFieldFutureDateSelectTimeSpent.ClientID%>').value = timespent;
                    document.getElementById('<%= txtDate.ClientID%>').value = toDate;
                }
            }



在上面的代码中,im检查文本框"txtDate"是否包含将来的日期,即比今天的日期大的日期,它将提示输入所花费的时间,然后将所花费的时间存储在隐藏字段中. >我无法将字符串转换为日期时间以进行比较.请指导我为解决此问题将进行哪些更改.

在此先感谢您.



In the above code i m checking that if text box ''txtDate'' will contain a future date i.e date greater then today''s date it will prompt for entering time spent and then store that time spent into an hidden field.
I m not able to convert string into date time for comparision. Please guide me that what the changes i ll make to solve this issue.

Thanks in advance.

推荐答案


这篇关于在javascript中将字符串与日期时间进行比较时出现问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-26 20:35
查看更多