PDA

View Full Version : Make sure input isn't "555" and jumping problem



Rockonmetal
04-11-2008, 01:32 AM
Hey, I'm not that good with javascript, at all, i have this piece of code from w3schools (which works for the first two inputs) the 3 inputs are for the phone input...
The code is here:


<head>
<script type="text/javascript">
function checkLen(x,y)
{
if (y.length==x.maxLength)
{
var next=x.tabIndex;
if (next<document.getElementById("booking").length)
{
document.getElementById("booking").elements[next].focus();
}
}
}
</script>
</head>
<body>
<label for="phone">Phone Number:</label>
<br /><span class="phone">
(<input size="3" tabindex="3" name="phone1" maxlength="3" onkeyup="checkLen(this,this.value)">)
-
<input size="3" tabindex="4" name="phone2" maxlength="3" onkeyup="checkLen(this,this.value)">
-
<input size="3" tabindex="5" name="phone3" maxlength="3" onkeyup="checkLen(this,this.value)">
</span>
</body>
I want to make sure that phone2 doesn't equal 555 and if it does, it disables the submit button...

if someone could also figure out why it won't jump from phone2 to phone3 even though the max length is full that would be stellar!

Thanks!

rangana
04-11-2008, 01:44 AM
Up the other code,,,I can't see the booking id yet ;)

Rockonmetal
04-11-2008, 09:19 PM
The whole thing is there...

<html>
<head>
<script type="text/javascript">
function checkLen(x,y)
{
if (y.length==x.maxLength)
{
var next=x.tabIndex;
if (next<document.getElementById("booking").length)
{
document.getElementById("booking").elements[next].focus();
}
}
}
</script>
<style type="text/css">
.phone{
font-family: Trebuchet Ms;
color: #444444;
font-size: 14px;
font-weight: bold;
}
.dankforms input, select{
background: url('dankforms/background.gif');
border: 1px solid #AAAAAA;
font-family: Trebuchet Ms;
color: #444444;
font-size: 14px;
font-weight: bold;
}
.dankforms textarea{
background-color: #FFFFFF;
border: 1px dashed #AAAAAA;
font-family: Trebuchet Ms;
color: #444444;
font-size: 14px;
font-weight: bold;
overflow: auto;
}
.dankforms fieldset{
font-family: Trebuchet Ms;
color: #4e4e4e;
font-weight: normal;
font-size: 10px;
border: 1px dashed #AAAAAA;
border-top: none;
padding-left: 15px;
width: 450px;
}
.dankforms legend{

font-family: Trebuchet Ms;
color: #0000FF;
font-weight: normal;
font-size: 10px;
text-indent: -10px;
}
.dankforms label{
border: none;
font-family: Trebuchet Ms;
color: #4e4e4e;
font-weight: normal;
font-size: 10px;
}
</style>
</head>
<body>
<form action="booking.php?step=2" method="post" class="dankforms" id="booking">
<fieldset><legend>Contacting You</legend>
<label for="fName">Your First Name:</label>
<br />
<input type="text" name="fName" size="15" maxlength="15" tabindex="1" />
<br />
<label for="lName">Your Last Name:</label>
<br />
<input type="text" name="lName" size="15" maxlength="15" tabindex="2" />
<br />
<label for="phone">Phone Number:</label>
<br /><span class="phone">
(<input size="3" tabindex="3" name="phone1" maxlength="3" onkeyup="checkLen(this,this.value)">)
-
<input size="3" tabindex="4" name="phone2" maxlength="3" onkeyup="checkLen(this,this.value)">
-
<input size="3" tabindex="5" name="phone3" maxlength="3" onkeyup="checkLen(this,this.value)">
</span>
<br />
<label for="site">Your Venue's site:</label>
<br />
<input type="text" value="http://" name="site" maxlength="100" size="50" tabindex="6" />

</fieldset>
<hr color="FEFEFE" />
<fieldset>
<legend>Venue Info</legend>
<label for="vName">Venue Name:</label>
<br />
<input type="text" name="vName" size="30" maxlength="30" tabindex="7" />
<br />
<label for="vAddress">Venue Address: like (10 Example Street)</label>
<br />
<input type="text" name="vAddress" size="50" maxlength="50" tabindex="8" />
<br />
<label for="vInfo">Venue Description:</label>
<br />
<textarea cols="50" rows="4" maxlength="400" tabindex="9" >
</textarea>
<br />Good info to include is stage size (width and length), whether there is a P.A system, inside or outside, most common music played onstage, whether there are bouncers, dance floor size, parking, and security. Must be able to host minors on stage. Friendly Enviroment and or staff? These are all things we would love to know before we even think about calling you up.
<br />
** We currently are only touring in the U.S **
<br />
<label for="state">State Venue Resides in:</label>
<br />
<select name="state" size="1" tabindex="10">
<!--State list Ridiculous long list -->
</select>
<br />
<label for="city">City which the Venue is in:</label>
<br />
<input type="text" name="city" size="20" maxlength="30" tabindex="11" />
<br />
</fieldset>
<fieldset>
<legend>How this is gonna go down...</legend>
This info is going to be emailed to our email account dedicated for booking. Once we look over the application we will call you up and talk with you about whether its plausible or totally not possible. If we it's plausible give us some rough dates and times of when the gig might happen. Then we will talk some more.
<br />
<br /><b>Notice:</b>
<br />Dank Lemon is located in the wonderful state of Virginia and still has their parents drive them around. We need atleast a month to plan out a show in the state of Virginia. If your venue is outside of the state of Virginia (even if its on the borderline) we need 2-3 months notice.
<br /><input type="submit" value="Send your Request" />
<br />
<br /><input type="reset" value="Reset Application" />


edit: I just put up the whole page...

Nile
04-11-2008, 09:24 PM
EDIT: Sorry, lol, I didn't know you we're the one asking.

rangana
04-12-2008, 12:30 AM
Try adding this in your script:


window.onload = function()
{
var phone2 = document.getElementById('booking').phone2;
var submit = document.getElementById('booking').mysubmit;
phone2.onblur = function()
{
var filter = Number(this.value);
if(filter == 555)
{
submit.disabled = 'disabled';
}
}
}


...Also give your submit button a name....use mysubmit for instance ;)

See if it helps ;)