Results 1 to 3 of 3

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

  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.

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

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

    I can only assume there is a problem with your isDate function.

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

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

    Is there an error message?

    If you are unsure how to see JS error messages, in IE it is shown as a small icon on the status bar with the text "Error on page". In Firefox it is under Tools -> Javascript Console.

    Also, don't use the "language" attribute of script tags. This is deprecated. Instead, use the "type" attribute.

    HTML Code:
    <script type="text/javascript">

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