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 5 of 5
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts

    form validation using java script not working?

    form validation using java script not working nothing happens when i press submit button why?


    Code:
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Online Bus Ticket Reservation</title>
    
    
    <script type="text/javascript">
    
    function validExpiryDate(form,monthInputName,yearInputName) {
    var month = form[monthInputName].value,
    year = form[yearInputName].value,
    d = new Date(),
    currentYear = d.getFullYear(),
    currentMonth = d.getMonth() + 1; //need to add 1, getMonth returns 0-11
    if (!/^\d{1,2}$/.test(month) ¦¦ !/^\d{4}$/.test(year)) {
    alert('Improper entry!');
    return false;
    } else if (year < currentYear ¦¦ (year == currentYear && month < currentMonth)) {
    alert('Card has expired!');
    return false;
    }
    return true;
    }
    
    window.onload = function () {
    document.payment.onsubmit = function () {
    MM_validateForm('fname', '', 'R', 'card_number_field1', '', 'RisNum', 'card_number_field2', '', 'RisNum', 'card_number_field3', '', 'RisNum', 'card_number_field4', '', 'RisNum', 'card_exp_month', '', 'RisNum', 'card_exp_year', '', 'RisNum');
    var bool1 = validExpiryDate(this,'card_exp_month','card_exp_year');
    var bool2 = document.MM_returnValue;
    return (bool1 && bool2);
    };
    };
    
    </script> 
    
    
    
    <link href="obrs.css" rel="stylesheet" type="text/css" />
    <!--[if IE 5]>
    <style type="text/css"> 
    /* place css box model fixes for IE 5* in this conditional comment */
    .twoColFixRtHdr #sidebar1 { width: 220px; }
    </style>
    <![endif]--><!--[if IE]>
    <style type="text/css"> 
    /* place css fixes for all versions of IE in this conditional comment */
    .twoColFixRtHdr #sidebar1 { padding-top: 30px; }
    .twoColFixRtHdr #mainContent { zoom: 1; }
    /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
    </style>
    <![endif]-->
    <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
    <style type="text/css">
    <!--
    .style1 {
    	color: #FFFF00;
    	font-weight: bold;
    }
    .style2 {
    	color: #FFFF66;
    	font-weight: bold;
    }
    #payment_box {
    	height: 300px;
    	width: 500px;
    	margin-top: 100px;
    	margin-left: 150px;
    }
    #payment_form {
    	height: 150px;
    	width: 400px;
    	margin-top: 40px;
    }
    .style3 {
    	font-size: 16px;
    	font-weight: bold;
    	color: #333333;
    }
    -->
    </style>
    
    
    </head>
    
    <body class="twoColFixRtHdr">
    
    <div id="container">
      <div id="header">
        <!-- end #header -->
        <img src="images/header" alt="OBTRS: Header" /></div>
      <div id="sidebar1">
        <!-- end #sidebar1 -->
        <img src="images/sidebar_slideshow" alt="" /><center><a href="pictureslideshow.html">Click Here</a></center>
        <div id="blogarea">
          <p class="style2">Casual Dining Restaurants</p>
          <p><br />
            Our family-style restaurants are the favorite of thousands of tourists and professional drivers alike. Our clean and friendly surroundings encourage people to stop and enjoy a wholesome meal with us when they travel. Our customers recognize our strong teamwork ethic as we provide them quality service.</p>
          <p><br />
              <span class="style1">Convenience Stores</span></p>
          <p><br />
            Our cashiers take pride in having the items on the shelf ready for our travelers when they stop. We know many are in a hurry and we need to be &quot;fast&quot; to meet their busy schedules. Some of our returning customers enjoy fresh coffee and we have it ready for them. The joint effort of our managers and associates creates a strong &quot;team spirit&quot; that provides the customers what they are looking for as they travel.</p>
        </div>
      </div>
      <div id="mainContent">
        <div id="nav">
          <script type="text/javascript">
    AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','760','height','30','src','images/nav_bar2','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','images/nav_bar2' ); //end AC code
        </script>
          <noscript>
          <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="760" height="30">
            <param name="movie" value="images/nav_bar2.swf" />
            <param name="quality" value="high" />
            <embed src="images/nav_bar2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="760" height="30"></embed>
          </object>
          </noscript>
        </div>
        
    
          <div class="style3" id="payment_box"> 
        
        <form name="payment" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
         
          <center>Make Payment<br />
            </center>
            <br /><br /><br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Card Holder's Name:&nbsp;*<input name="fname" type="text" id="fname" />
        <br /><br />
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Card Number:
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <INPUT name="card_number_field1"  type="text" id="card_number_field1" size="4" maxlength="4" />
            &nbsp;<INPUT name="card_number_field2" type="text" id="card_number_field2" size="4" maxlength="4">
            &nbsp;<INPUT name="card_number_field3" type="text" id="card_number_field3" size="4" maxlength="4">
            &nbsp;<INPUT name="card_number_field4" type="text" id="card_number_field4" size="4" maxlength="4">
            <br /><br />
    
              
    		
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Card Expiry Date:&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;<INPUT name="card_exp_month" type="text" id="card_exp_month" size="2" maxlength="2">*
           /*
    		<INPUT name="card_exp_year" type="text" id="card_exp_year" size="4" maxlength="4">
    		</center><br /><br />
            <center><input name="submit" type="submit" value="Submit" /></center>
            
        </form>
        
        </div>
        <!-- end #mainContent -->
      </div>
      <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
      <br class="clearfloat" />
      <div id="footer">
        <p><a href="aboutus.html">About us</a> |<a href="feedback.html"> Feedback</a> |<a href="faqs.html"> FAQs</a> | <a href="terms.html">Terms &amp; Conditions</a> | <a href="contactus.html">Contact us</a></p>
        <p> 2009 Copyright - Shah Abdul Latif University Khairpur</p>
        <!-- end #footer -->
      </div>
      <!-- end #container -->
    </div>
    
    </body>
    </html>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Where is your MM_validateForm() function?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    what does that do? can u show me where the mistake is what should i do?

  • #4
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    any one ?

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    MM_validateform function refers to a script that DW put in for you and it looks like you may have deleted it. Search google for the function and you'll probably find what you need. It needs to be in your document. Also it helps to actually TRY things on your own. We aren't here to hold your hand. We are here to help.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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