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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2008
    Posts
    126
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Help with Re-enter field

    I have this Form, where there is a field that requires a number to be entered into it. How can I add the function where the number has to be re-entered into the next field, and match the original number field? I want to check that the number in both inputs is the same before the form will be submitted successfully.
    Thanks

    Code:
    <html>
    <head>
      <title></title>
    
    
    </head>
    <body>
    <br>
    <h1 style="border-bottom:1px solid #dddcdc;"><br><center> Form</center></h1>
    
            <p><center><font face="verdana"><font size="2"><font color=#000000;"></font></font></p>
    
            <p><font face="verdana"><font size="2"><font color=#800000;">Please complete the simple form below.</font></font></p>
    
            <p><font face="verdana"><font size="2"><font color=#000000;">.</font></font></p>
    
            <p><font face="verdana"><font size="2"><font color=#000000;"> </font></font></center></p>
    
    <!--<div style="height: 80px; background-color: #336699;">
      <span class="page_title"><span class="form_title">Form</span></span>
    </div>-->
    
    <br />
    
    <table cellpadding="0" cellspacing="0" align="center" width="600">
    <tr>
      <td>
        <font face="verdana"><font size="2"><font color=#800000;">[var.result]</font></font><font color="red"><strong>[var.error]</strong></font><br>
        <hr size="1" />
        <br />
    
        <form action="/page.php?page=14" method="post" name="contact_us" onSubmit="return capCheck(this);">
    
    
        <table cellpadding="0" width="100%">
        <tr>
    		  <td width="10" class="required_field">*</td>
          <td width="80">First Name:</td>
          <td><input type="text" name="name" maxlength="50" style="width:300px" /></td>
        </tr>
        <tr>
    		  <td class="required_field">*</td>
          <td>Last Name:</td>
          <td><input type="text" name="email" maxlength="40" style="width:300px" /></td>
        </tr>
        <tr>
    		  <td class="required_field">*</td>
          <td>Type:</td>
          <td><input type="text" name="custom1" maxlength="20" style="width:300px" /></td>
        </tr>
        <tr>
    		  <td class="required_field">*</td>
          <td>Number:</td>
          <td><input type="text" name="custom2" maxlength="20" style="width:300px" /></td>
        </tr>
        <tr>	  
    <tr>
          <td class="required_field">*</td>
          <td>Enter Image Code:</td>
          <td><input type="text" value="" name="captext" style="width: 100px" maxlength="6" /></td>
        </tr>
    <tr>
          <td></td>
          <td><a onclick="refresh_security_image(); return false;" style="cursor:pointer;"><u>Refresh Image</u></a></td>
          <td><img src="includes/captcha.php" border="0" id="verificiation_image" /></a></td>
        </tr>
        </table>
    <br>
    
    <br>
        <p>
          <input type="hidden" name="submited" value="1" />
          <input type="submit" name="submit" value="Submit" />
        </p>
    
        </form>
    
      </td>
    </tr>
    </table>
    <script type="text/javascript">
      <!--
      function refresh_security_image() {
    
      	var new_url = new String("[var.base_url]/includes/captcha.php?width=132&amp;height=36&charcators=");
    	new_url = new_url.substr(0, new_url.indexOf("width=") + 37);
    	// we need a random new url so this refreshes
    	var chr_str = "123456789";
    	for(var i=0; i < 6; i++)
    	new_url = new_url + chr_str.substr(Math.floor(Math.random() * 2), 1);
    	document.getElementById("verificiation_image").src = new_url;
      }
      -->
     </script>
    
     <!-- captcha start -->
     <script type="text/javascript" id="clientEventHandlersJS" language="javascript">
     <!--
     	function capCheck(theForm) {
    		var xmlhttp;
    		var sReply;
    		DataToSend = "action=process&captext=" + escape(theForm.captext.value);
    		if (window.XMLHttpRequest) {
    			xmlhttp=new XMLHttpRequest();
    			xmlhttp.open("POST",'includes/process.php',false);
    			xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    			xmlhttp.send(DataToSend);
    			sReply = xmlhttp.responseText;
    		} else if (window.ActiveXObject) {
    			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    			xmlhttp.open("POST",'includes/process.php',false);
    			xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    			xmlhttp.send(DataToSend);
    			sReply = xmlhttp.responseText;
    		}
    		if (sReply == "good") {
    			return true;
    		} else if (sReply == "bad") {
    			alert("Security code not valid, please try again"); return false;
    		} else if (sReply == "") {
    			alert("You must enter the security code"); return false;
    		} else {
    			alert("Error"); return false;
    		}
    	}
      -->
      </script>
      <!-- captch end -->
    
    </body>
    </html>

  • #2
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here try something like this.
    Edit your fields from:
    <input type="text" name="custom1" maxlength="20" style="width:300px" />
    <input type="text" name="custom2" maxlength="20" style="width:300px" />
    <input type="submit" name="submit" value="Submit" />

    to:
    <input type="text" id="match1" name="custom1" maxlength="20" style="width:300px" onchange="matchCheck()" />
    <input type="text" id="match2" name="custom1" maxlength="20" style="width:300px" onchange="matchCheck()" />
    <input type="submit" id="submitbtn" name="submit" value="Submit" disabled="disabled" />

    then paste this function:
    Code:
    function matchCheck(){
      var matchNums = new Array();
      var matchNums[0] = document.getElementById("match1");
      var matchNums[1] = document.getElementById("match2");
      var SubmitButton = document.getElementById("submitbtn");
      if (matchNums[0] === matchNums[1]){
        SubmitButton.disabled = false;
      }
      else{
        SubmitButton.disabled = true;
    }


  •  

    Posting Permissions

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