Wednesday, May 13, 2009

Javascript turn the submit button off when it press

//turn the submit button off when they submit the order. This prevents double (or more) orders

Put below code to Page_Load event.

this.btnComplete.Attributes.Add("onclick", "this.value='Please wait...';this.disabled = true;" + Page.ClientScript.GetPostBackEventReference(this.btnComplete, ""));


Here is button asp control.

<asp:button id=”btnComplete” text=”Complete” runat=”server”/>

Javascript Text Counter

Here is the javascript text counter that you write down the text in TEXTAREA box,it show the available text count. Put the javascript between <head> and </head>.

//Handle textarea comment and URL description character count
<script type="text/javascript">
function textCounter(field, countfield, maxlimit)
{
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}
</script>

<span>Comments:</span>
<span>Only 200 char allowed</span>
<textarea id="COMMENTS" onblur="this.style.backgroundColor='#ffffff'" onfocus="this.style.backgroundColor='#FFFCF9'" onkeyup="textCounter(this.form.COMMENTS,this.form.remLen,200);" onkeydown="textCounter(this.form.COMMENTS,this.form.remLen,200);" rows="7" cols="60" name="COMMENTS" style="background-color: rgb(255, 255, 255);">
</textarea>
<input type="text" readonly="" value="200" maxlength="3" size="3" name="remLen"/>
<span>Char count</span>