ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Check given Date is Greater than Today using JavaScript<p>Hi&nbsp;<a class="username" rel="gouthamgou">gouthamgou,</a></p> <p>Refer below code.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <div class="demo_block"> <pre class="brush: html">&lt;span&gt;Invalid Format&lt;/span&gt; &lt;input type=&#34;text&#34; id=&#34;masterDataFeedDate_Id&#34; maxlength=&#34;10&#34; /&gt; &lt;input type=&#34;button&#34; name=&#34;&#34; value=&#34;Validate&#34; onclick=&#34;Validate()&#34; /&gt; &lt;script type=&#34;text/javascript&#34;&gt; var isShift = false; var seperator = &#34;/&#34;; window.onload = function () { //Reference the Table. var tblForm = document.getElementById(&#34;masterDataFeedDate_Id&#34;); //Reference all INPUT elements in the Table. var inputs = document.getElementsByTagName(&#34;input&#34;); //Loop through all INPUT elements. for (var i = 0; i &lt; inputs.length; i++) { //Check whether the INPUT element is TextBox. if (inputs[i].type == &#34;text&#34;) { //Check whether Date Format Validation is required. if (inputs[i].className.indexOf(&#34;date-format&#34;) != 1) { //Set Max Length. inputs[i].setAttribute(&#34;maxlength&#34;, 10); //Only allow Numeric Keys. inputs[i].onkeydown = function (e) { return IsNumeric(this, e.keyCode); }; //Validate Date as User types. inputs[i].onkeyup = function (e) { ValidateDateFormat(this, e.keyCode); }; } } } }; function IsNumeric(input, keyCode) { if (keyCode == 16) { isShift = true; } //Allow only Numeric Keys. if (((keyCode &gt;= 48 &amp;&amp; keyCode &lt;= 57) || keyCode == 8 || keyCode &lt;= 37 || keyCode &lt;= 39 || (keyCode &gt;= 96 &amp;&amp; keyCode &lt;= 105)) &amp;&amp; isShift == false) { if ((input.value.length == 4 || input.value.length == 7) &amp;&amp; keyCode != 8) { input.value += seperator; } return true; } else { return false; } }; function ValidateDateFormat(input, keyCode) { var dateString = input.value; if (keyCode == 16) { isShift = false; } var regex = /^(19[5-9][0-9]|20[0-4][0-9]|2050)[-/](0?[1-9]|1[0-2])[-/](0?[1-9]|[12][0-9]|3[01])$/; //Check whether valid dd/MM/yyyy Date Format. if (regex.test(dateString) || dateString.length == 0) { ShowHideError(input, &#34;none&#34;); } else { ShowHideError(input, &#34;block&#34;); } }; function ShowHideError(textbox, display) { var row = textbox.parentNode.parentNode; var errorMsg = document.getElementsByTagName(&#34;span&#34;)[0]; if (errorMsg != null) { errorMsg.style.display = display; } }; function Validate() { //Get the date from the TextBox. var dateString = document.getElementById(&#34;masterDataFeedDate_Id&#34;).value; var dtCurrent = new Date(); var parts = dateString.split(&#34;/&#34;); var dt = new Date(parts[1] + &#34;/&#34; + parts[2] + &#34;/&#34; + parts[0]); if(dt &gt; dtCurrent){ alert(&#39;Given date is greater than the current date.&#39;); } }; &lt;/script&gt;</pre> </div> <p><a class="demo button orange btn btn-red">Demo</a></p>https://www.aspforums.net:443/Threads/923476/Check-given-Date-is-Greater-than-Today-using-JavaScript/https://www.aspforums.net:443/Threads/923476/Check-given-Date-is-Greater-than-Today-using-JavaScript/Mon, 19 Nov 2018 06:19:27 GMT