Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript stops working

    I have a form that calls a javascript function to validate a date:

    <form name="frmSelect" method="Post" action="allxml.asp" onSubmit="return ValidateForm()">


    the function is called if I only have a little bit of code like this:

    <script language="javascript">

    function ValidateForm()
    {

    alert("matchArray = null");

    }

    </script>


    but once I add all of the code the validation doesn't run.
    any Ideas what the problem could be?
    thanks

    part of my code:
    Code:
    <?xml version="1.0" encoding="UTF-16"?>
    <html>
    <head>
    <title>Time </title>
    <script language="javascript">
    		
    				function ValidateForm()
    				{
    					var dteDate;
    					var day, month, year;
    					dt=document.frmSelect.txtDate.value;
    					var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;
    					var matchArray = dt.match(datePat);
    					
    
    					if (matchArray == null){
    						alert("matchArray = null");
    						return false;
    					}
    					month = matchArray[1];
    					day = matchArray[3];
    					year = matchArray[5]; 
    					month--;
    
    					dteDate=new Date(year,month,day);
    					 if((day==dteDate.getDate()) &amp;&amp; (month==dteDate.getMonth()) &amp;&amp; (year==dteDate.getFullYear()))
    						return true;
    					alert("invalid date - day " +day+" month " +month+" year "+ year);
    					return false
    				}
    
    			</script>
    </head>
    <body>
    <form name="frmSelect" method="Post" action="allxml.asp" onSubmit="return ValidateForm()">

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,859
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    There might be some error in your javascript code. To debug this, get a copy of firebug for your firefox first(if you don't have one)

    After that change your input's type from submit to button and then move the function call from the onsubmit of your form to the onclick of your button. You could then find the erroneous statement with the help of firebug. After sorting the error, you may revert it.
    Code:
    <form name="frmSelect" method="Post" action="allxml.asp" >
    ........
    <input type="button" onclick="return ValidateForm();" value="Submit"/>
    </form>
    PS: validate and fix all the errors in your markup.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you the second link helped

    I think DocTYPE was the problem this is the change to the html file:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
    <head>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-16">
    and this is the change to the xsl file that tranformes an xml file:
    Code:
     <xsl:output method="html"
    		omit-xml-declaration="yes"
    		doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    	doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" indent="yes"/>
    Last edited by pookypook; 03-23-2009 at 02:25 PM. Reason: code brackets


  •  

    Posting Permissions

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