...

View Full Version : [resolved] javascript - onEditFieldFocus change button texts



jthunder
01-07-2012, 12:00 AM
I have this javascript on top of my HTML codes, that enables the "Free Trial" button if the Checkbox=On.
but since I am not a programmer, I need a good mind to help me edit this


What I need is to Edit this so that,
If focus on Voucher Code field and have at least 6 bytes entered, and also the CheckBox=ON, I want the "Trial" button to change to "Confirm".


<script language="Javascript" type="text/javascript">
function enable(){
if (document.agreement_form.agreed.checked==''){
document.agreement_form.submit_button.disabled=true
}else{
document.agreement_form.submit_button.disabled=false
}
}
</script>

<div style="float:right;width:200px;margin-left:15px;padding-left:15px;margin-top:15px;border-left:2px dotted #99CC00">

<span style="font-weight:bold;font-family:Tahoma;font-size:10pt;">Voucher Code:</span><br/>

<form style="font-family:Tahoma;font-size:8pt;" method="GET" action="$authaction" name="agreement_form">
<input name="tok" value="$tok" type="hidden"/>
<input name="redir" value="$redir" type="hidden"/>
<input size="12" name="voucher" type="password"/>&nbsp;
<button type="SUBMIT" disabled="disabled" name="submit_button"><strong>&nbsp; Free Trial&nbsp; </strong></button>

<p>
</p>
<input name="agreed" onchange="enable()" type="checkbox"/> Signed & agreed to all terms and conditions.
</form>

xelawho
01-07-2012, 12:46 AM
like this you mean?



<html>
<head>
</head>
<body>
<script type="text/javascript">
function enable(){
if (document.agreement_form.agreed.checked==true){
document.agreement_form.submit_button.disabled=false;
if (document.agreement_form.voucher.value.length>5){
document.agreement_form.submit_button.value="confirm";
}
}else{
document.agreement_form.submit_button.disabled=true;
}
}
</script>

<div style="float:right;width:200px;margin-left:15px;padding-left:15px;margin-top:15px;border-left:2px dotted #99CC00">

<span style="font-weight:bold;font-family:Tahoma;font-size:10pt;">Voucher Code:</span><br/>

<form style="font-family:Tahoma;font-size:8pt;" method="GET" action="$authaction" name="agreement_form">
<input name="tok" value="$tok" type="hidden"/>
<input name="redir" value="$redir" type="hidden"/>
<input size="12" name="voucher" onkeyup="enable()" type="password"/>&nbsp;<br>
<input type="submit" disabled="true" name="submit_button" value="Free Trial"/>

<p>
</p>
<input name="agreed" onclick="enable()" type="checkbox"/> Signed & agreed to all terms and conditions.
</form>
</body>
</html>

Logic Ali
01-07-2012, 01:39 AM
This will also run the check when the checkbox is toggled:

<html>
<head>
</head>
<title>TEST</title>
<body>

<div style="float:right;width:200px;margin-left:15px;padding-left:15px;margin-top:15px;border-left:2px dotted #99CC00">

<span style="font-weight:bold;font-family:Tahoma;font-size:10pt;">Voucher Code:</span><br/>

<form style="font-family:Tahoma;font-size:8pt;" method="GET" action="$authaction" name="agreement_form">
<input name="tok" value="$tok" type="hidden"/>
<input name="redir" value="$redir" type="hidden"/>
<input size="12" name="voucher" id = "voucher" type="password"/><br>
<button type="SUBMIT" disabled="xdisabled" name="submit_button"><strong>&nbsp; Free Trial&nbsp; </strong></button>
<p>
<input name="agreed" onclick="enable(this, submit_button)" type="checkbox"/> Signed & agreed to all terms and conditions.
</form>
</div>

<script type="text/javascript">

function enable( box, btn )
{
btn.disabled = !box.checked;

fCheck.call( box.form.voucher );
}

document.getElementById( "voucher" ).onkeyup = fCheck

function fCheck()
{
var s1 = "<strong>&nbsp; Free Trial&nbsp; </strong>",
s2 = "<strong>&nbsp; Confirm&nbsp; </strong>" ;

this.form.submit_button.innerHTML = ( this.value.length >= 6 && this.form.agreed.checked ? s2 : s1 );
}

</script>
</body>
</html>

jthunder
01-07-2012, 06:42 PM
Hey Xelowho and Logic Ali. Thanks to both of you. I tried them both and they are great. Have a great day and hopefully will head this place again. Thanks again.

I have posted another help about PHP IP tracking behind the proxy. Maybe you can give it shot? Thanks again guys.
http://www.codingforums.com/showthread.php?p=1178353#post1178353

jthunder
01-08-2012, 03:32 AM
I missed this one on this thread,

I need to add to the javacscript to hide the codes. Is there a way to turn off the "View Code" on the user browser so no one can see the source behind. Is there away to do this. Thanks again,'

xelawho
01-08-2012, 03:35 AM
No. Passwords and other sensitive information should be stored on the server. Treat anything you do in javascript as visible to everybody.

jthunder
01-08-2012, 05:00 AM
Thanks for the info. Have a nice evening.

jthunder
01-12-2012, 06:33 PM
HI Do you think you can help me with this?
http://www.codingforums.com/showthread.php?t=248208

Thanks in advance.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum