Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
check input boxes an "hidden" input box
Old 09-17-2009, 04:36 PM check input boxes an "hidden" input box
MDwebdev85's Avatar
Extreme Talker

Posts: 209
Location: North Carolina
Trades: 0
I have a script to check and prompt for input boxes that arent filled out that are specified in the script. I also have a drop down with a few options. One of the options, when selected shows the "hidden" text box. The script works very well except when the "hidden" text box is not activated by selecting that specific option, the script still prompts to enter text in the box, even though its hidden. My javascript skills are little to none, can someone help me out with this? I just need it to "not" prompt unless the box is shown. Thanks, I can post my code if needed upon request. Thanks,
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
MDwebdev85 is online now
Reply With Quote
View Public Profile Visit MDwebdev85's homepage!
 
 
Register now for full access!
Old 09-17-2009, 07:50 PM Re: check input boxes an "hidden" input box
Junior Talker

Posts: 2
Name: James Fuller
Location: Edgewood, WA
Trades: 0
Would need to see your validation script. Are you checking for visibility of the textbox before making it mandatory? Look for something along those lines if you don't have a chance to post your code.
__________________
James Fuller
jafuller is offline
Reply With Quote
View Public Profile
 
Old 09-17-2009, 08:47 PM Re: check input boxes an "hidden" input box
MDwebdev85's Avatar
Extreme Talker

Posts: 209
Location: North Carolina
Trades: 0
Jafuller --- my code is below...any help would be greatly appreciated.

Scripts:

<script type="text/javascript">
function ToogleTextbox(pValue) {
var textBox = document.getElementById('FlyerNumber');
if(pValue) {
textBox.style.display = "block";
}
else {
textBox.style.display = "none";
}
}
</script>
<!---end display txt box on selection--->
<script type="text/javascript">
function ValidateContactForm()
{
var FirstName = document.form1.FirstName;
var LastName = document.form1.LastName;
var DaytimePhone = document.form1.DaytimePhone;
var Email = document.form1.Email;
var FlyerNumber = document.form1.FlyerNumber;
if (FirstName.value == "")
{
window.alert("Please enter your first name.");
FirstName.focus();
return false;
}
if (LastName.value == "")
{
window.alert("Please enter your last name.");
LastName.focus();
return false;
}
if (DaytimePhone.value == "")
{
window.alert("Please enter your daytime phone number.");
DaytimePhone.focus();
return false;
}
if (Email.value == "")
{
window.alert("Please enter your email address.");
Email.focus();
return false;
}
if (FlyerNumber.value == "")
window.alert("Please enter a flyer number.");
FlyerNumber.focus() ;
return false;
}
</script>


Form:

<form name="form1" id="form1" action="<?php echo $editFormAction; ?>" method="post" onSubmit="return ValidateContactForm();"/>
<tr>
<td width="99">First Name</td>
<td width="192"><input name="FirstName" type="text" id="FirstName" width="100%"/></td>
<td width="8">&nbsp;</td>
<td width="163" align="center">&nbsp;</td>
</tr>
<tr>
<td >Last Name </td>
<td><input name="LastName" type="text" id="LastName" width="100%"/></td>
<td>&nbsp;</td>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td >Daytime Phone</td>
<td><input name="DaytimePhone" type="text" id="DaytimePhone" width="100%"/></td>
<td>&nbsp;</td>
<td align="center"> </td>
</tr>
<tr>
<td>Evening Phone</td>
<td><input name="EveningPhone" type="text" id="EveningPhone" width="100%"/></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td >Home Address</td>
<td><input name="Address" type="text" id="Address" width="100%"/></td>
<td>&nbsp;</td>
<td align="center"></td>
</tr>
<tr>
<td>County</td>
<td><input name="County" type="text" id="County" width="100%"/></td>
<td></td>
<td align="center"></td>
</tr>
<tr>
<td >City</td>
<td><input name="City" type="text" id="City" width="100%"/></td>
<td>&nbsp;</td>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td >State</td>
<td><input name="State" type="text" id="State" width="100%"/></td>
<td>&nbsp;</td>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td >Zip Code</td>
<td><input name="Zip" type="text" id="Zip" width="100%"/></td>
<td>&nbsp;</td>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td>Email</td>
<td><input name="Email" type="text" id="Email" width="100%"/></td>
<td>&nbsp;</td>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td >Product Interest</td>
<td>
<select name="Service" id="Service" onchange="javascript: ToogleTextbox(this.value == 'null');">
<option >Please Select a Service</option>
<option></option>
<option>HUD 203k Friendly</option>
<option>Replacement Windows</option>
<option>Siding</option>
<option>Roofing</option>
<option>Room Additions</option>
<option>Sunrooms</option>
<option>Basement Refinishing</option>
<option>Garages</option>
<option>Decks</option>
<option>Patios</option>
<option>Walkways</option>
<option>Gazebos</option>
<option>Screen Porches</option>
<option>Fencing</option>
</select></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<tr>
<td>Referred By</td>
<td>
<select name="ReferredBy" id="ReferredBy" onchange="javascript: ToogleTextbox(this.value == 'null');">
<option>Internet Search</option>
<option>Telephone Book</option>
<option>Any Options</option>
<option id="PromotionalFlyer" value="null">Promotional Flyer</option>
</select>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
****This is the text box that I only want to be checked for values IF the option ID of "PromotionalFlyer" is selected*******
<td><input name="FlyerNumber" type="text" id="FlyerNumber" style="display: none;" width="100%"/></td>
<td>&nbsp;</td>
</tr>
<td align="center"></td>
</tr>
</table>
<table width="463" height="59" border="0" align="center">
<tr>
<td align="center" >
<span ><br/>Please tell us more.<br/><br/>
<textarea name="Comments" rows="4"cols="70%%"id="Comments" style="overflow"></textarea>
</span>
<p>
<input type="hidden" name="MM_insert" value="form1" />
</p>
</td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Submit" /></td></form>
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by MDwebdev85; 09-17-2009 at 08:50 PM..
MDwebdev85 is online now
Reply With Quote
View Public Profile Visit MDwebdev85's homepage!
 
Old 09-19-2009, 08:32 PM Re: check input boxes an "hidden" input box
MDwebdev85's Avatar
Extreme Talker

Posts: 209
Location: North Carolina
Trades: 0
any ideas??
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
MDwebdev85 is online now
Reply With Quote
View Public Profile Visit MDwebdev85's homepage!
 
Old 09-20-2009, 12:49 PM Re: check input boxes an "hidden" input box
davelf's Avatar
Novice Talker

Posts: 9
Name: David Demetrius
Location: earth
Trades: 0
i have a simple code to solve that:

Code:
<form action="">
<select onchange="if (this.selectedIndex==2){this.form['box'].style.visibility='visible'}else {this.form['box'].style.visibility='hidden'};">
<option value="">0</option>
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
</select>
<input style="visibility:hidden;" type="text" name="box">
</form>
copy paste this code to see how it's works, and then use it to solve the problem.
good luck

Last edited by davelf; 09-20-2009 at 12:51 PM..
davelf is offline
Reply With Quote
View Public Profile
 
Old 09-20-2009, 01:25 PM Re: check input boxes an "hidden" input box
MDwebdev85's Avatar
Extreme Talker

Posts: 209
Location: North Carolina
Trades: 0
Hey thanks a lot. I'll give it a try and let you know how it works.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
MDwebdev85 is online now
Reply With Quote
View Public Profile Visit MDwebdev85's homepage!
 
Old 09-20-2009, 01:48 PM Re: check input boxes an "hidden" input box
MDwebdev85's Avatar
Extreme Talker

Posts: 209
Location: North Carolina
Trades: 0
ok, I tried your script however, when the text box is visible, it doesnt prompt if there are no values in the box....
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
MDwebdev85 is online now
Reply With Quote
View Public Profile Visit MDwebdev85's homepage!
 
Old 09-20-2009, 06:01 PM Re: check input boxes an "hidden" input box
Banned

Posts: 41
Trades: 0
I tried it also on local server and could not locate the issue
seoconsult is offline
Reply With Quote
View Public Profile
 
Old 09-20-2009, 10:48 PM Re: check input boxes an "hidden" input box
MDwebdev85's Avatar
Extreme Talker

Posts: 209
Location: North Carolina
Trades: 0
well, I got the script to work, everything is verifying that the required fields are filled out, but I still cant get it to only verify ONLY if the hidden text box is visible to the user.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
MDwebdev85 is online now
Reply With Quote
View Public Profile Visit MDwebdev85's homepage!
 
Old 09-21-2009, 04:18 AM Re: check input boxes an "hidden" input box
davelf's Avatar
Novice Talker

Posts: 9
Name: David Demetrius
Location: earth
Trades: 0
try this code:

Code:
<html>
<script language="javascript">
function validasi()
{
    var nama=form1.box.value;

    if(nama == "")
    {
        alert("check your field");
        form1.box.focus();
    }
    else
        alert("success")
}


function btnSubmit()
{
    validasi();
}

</script>
<body>
<form name="form1">
<select onchange="if (this.selectedIndex==2){this.form['box'].style.visibility='visible'}else {this.form['box'].style.visibility='hidden'};">
<option value="">0</option>
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
</select>

<input style="visibility:hidden;" type="text" name="box"></input>
<input type="button" value="Submit" name="submit" onClick="btnSubmit()"></input>                    
</form>
</body>

</html>
good luck
davelf is offline
Reply With Quote
View Public Profile
 
Old 09-21-2009, 09:15 AM Re: check input boxes an "hidden" input box
MDwebdev85's Avatar
Extreme Talker

Posts: 209
Location: North Carolina
Trades: 0
Davelf -- I'm not sure if you understand exactly what I am trying to do, the second code you posted does the same thing that I already have. I can already verify and prompt if there is nothing in the required fields. What I need is to ONLY check that text field IF it is visible. Follow me?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
MDwebdev85 is online now
Reply With Quote
View Public Profile Visit MDwebdev85's homepage!
 
Reply     « Reply to check input boxes an "hidden" input box
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.43169 seconds with 12 queries