...

View Full Version : Mandatory text field



zachmedia
12-28-2006, 11:44 PM
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?


<!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>

david_kw
12-29-2006, 12:31 AM
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

zachmedia
12-29-2006, 12:38 AM
that was it david_kw!

thank you very much!
:thumbsup:
-zachary



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum