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
    Dec 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Mandatory text field

    Hallo,
    I am trying to make a Javascript code for my text field that doesn't allow the user to continue unless the "Account Number" is filled in. I thought I did it right, but apparently not. Is it because the submit button's value is "image" ? or is it because I have no idea what I am doing and below is more like a Frankenstein code?
    Thanks in advance
    -Zachary



    Here is my code, can you please tell me where I've got it wrong?

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; 
    
    charset=ISO-8859-1">
    <title>Paypal</title>
    <meta name="GENERATOR" content="WYSIWYG Web Builder - 
    
    http://www.wysiwygwebbuilder.com">
    </head>
    <body bgcolor="#000000" text="#000000" 
    
    style="background-attachment:fixed;background-repeat:no-repeat;">
    
    <style type="text/css" media="screen"><!--
    #layer1   { visibility: visible; position: absolute; z-index: 1; top: 
    
    0; left: 0; width: 100%; height: 100% }
    #layer2   { visibility: visible; position: absolute; z-index: 2; top: 
    
    63px; left: 55px; width: 100%; height: 100% }
    --></style>
    	</head>
    
    	<body bgcolor="#ffffff">
    
    		<div align="center">
    			<div id="layer1">
    				<div id="layer2">
    					<div align="center">
    						<table width="100%" 
    
    border="0" cellspacing="0" cellpadding="0" align="center" height="600">
    							<tr>
    								<td>
    									
    
    <center>
    <SCRIPT language="JavaScript">
    <!--
    function noEntry() {
    if (document.tmaster.os0_1.value.length<1) {
    alert("Please fill in Your Account Number");
    return false; }
    else { return true; }
    }
    // -->
    </SCRIPT><br>
    									
    
    	<form name="tmaster" 
    
    action="https://www.paypal.com/cgi-bin/webscr" onsubmit="return 
    
    noEntry()" method="post">
    									
    
    		<div align="center">
    									
    
    			
    <input type="hidden" name="cmd" value="_xclick"> 
    <input type="hidden" name="business" value="gmkfit@yahoo.com"> <input 
    
    type="hidden" name="item_name" value="Online Payment - Orlando"> 
    <input type="hidden" name="no_shipping" value="2"> 
    <input type="hidden" name="return" value="http://www.turfmaster.cc"> 
    <input type="hidden" name="cancel_return" 
    
    value="http://www.turfmaster.cc"> 
    <input type="hidden" name="currency_code" value="USD"> 
    <input type="hidden" name="lc" value="US"> 
    <input type="hidden" name="bn" value="PP-BuyNowBF">
    									
    
    			<table>
    <tr>
    <td><b><font size="5">Orlando Service Area - Paypal 
    
    Payment</font></b></td>
    </tr>
    </table>
    <table>
    									
    
    				<tr>
    									
    
    					<td><input type="hidden" 
    
    name="on_0" value="Account Number"><b>Account Number</b></td>
    									
    
    					<td><input type="text" 
    
    name="os_0" maxlength="200"></td>
    									
    
    				</tr>
    
    
    									
    
    			</font></table>
    
    <input type="image" 
    
    src="https://www.paypal.com/en_US/i/btn/x-click-but6.gif" border="0" 
    
    name="button" alt="Make payments with PayPal - it's fast, free and 
    
    secure!"> 
    <img alt="" border="0" 
    
    src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" 
    
    height="1">
    </div>
    
    
    									
    
    	</form>
    									
    
    </center>
    								</td>
    							</tr>
    						</table>
    					</div>
    				</div>
    				<img 
    
    src="http://www.turfmaster.cc/Images/tmaster3.png" 
    
    align="middle"></div>
    		</div>
    		<p></p>
    	
    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I didn't test it but it looks like you have the wrong name. The html shows:

    <input type="text" name="os_0" maxlength="200">

    but your javascript shows:

    if (document.tmaster.os0_1.value.length<1) {

    So try making that if statement:

    if (document.tmaster.os_0.value.length<1) {

    In the future try to put long code in a CODE area (use the # button above the text entry area).

    david_kw

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that was it david_kw!

    thank you very much!

    -zachary


  •  

    Posting Permissions

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