Results 1 to 3 of 3

Thread: Comparing date with today's date (Java Script)

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2004
    Posts
    100

    Comparing date with today's date (Java Script)

    Hi all.
    I am new to Java Script.
    I try to make function to compare date with current date.
    If the date entered by the user is greater than current date, it will display alert message.
    However, it is not functioning.
    Can anyone explain to me what is wrong with the function.
    And, correct me if I am wrong.
    Thanks in advance.

    Below is the function.
    HTML Code:
    <script language="javascript1.2">
    function tarikh_lantikan()
    {
    	valf = "dd/MM/y";
    	var myDate = document.form1.tarikhmula.value;	
    	var today = new Date();
    	myDate2 = isDate(myDate,valf);
    	today2 = isDate(today,valf);
    	if (myDate2 > today2)
    	{
    		alert('Tarikh salah.');
    		document.form1.tarikhmula.focus();
    		return false;
    	}
    }
    </script>
    Last edited by azrina; Apr 24th, 2006 at 03:51 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width