Subscribe to Subscribers
Talk to Webmaster Tony John

Forums » .NET » JavaScript »

Java Script not working in Firefox


Posted Date: 08 Sep 2012      Posted By:: Aman Gandhi     Member Level: Gold    Member Rank: 402     Points: 5   Responses: 4



i am using below javascript in my applicaion. its working fine in IE but not working Properly in firefox.


<script type="text/javascript">
function CountChars(CharLimit,InputID,OutputID) {
var enterchar;
var textboxvalue;
var remainingchars;
enterchar = document.getElementById(InputID).value.length;
textboxvalue = document.getElementById(InputID).value;
remainingchars = CharLimit - enterchar;
document.getElementById(OutputID).innerHTML = remainingchars + " Characters Left(max:156 Characters)";
if (remainingchars <= 0) {
document.getElementById(OutputID).innerHTML="0 Characters Left(max:156 Characters)";
alert("you have reached the limit");
document.getElementById(InputID).innerHTML = textboxvalue.substring(0, CharLimit);
}
}

</script>


its working partially. its calculating the remaining char but substring fun is not working in firefox.

Aman Gandhi
comman sense is not so comman........




Responses

#688008    Author: Sreedevi U.V      Member Level: Gold      Member Rank: 362     Date: 08/Sep/2012   Rating: 2 out of 52 out of 5     Points: 1

Hi,
Please find the attached file for the working code.
Thanks,
Sreedevi



substrin.html
 
#688010    Author: Sreedevi U.V      Member Level: Gold      Member Rank: 362     Date: 08/Sep/2012   Rating: 2 out of 52 out of 5     Points: 2

Hi,
In my previous post I set the limit to 5.Please find the attached file (substringfun.html) for the working code.

Thanks,
Sreedevi



substringfun.html
 
#688015    Author: Aman Gandhi      Member Level: Gold      Member Rank: 402     Date: 08/Sep/2012   Rating: 2 out of 52 out of 5     Points: 1

thanks sridevi

but your file is also showing same problem. substring function is not working.

Aman Gandhi
comman sense is not so comman........






 
#688093    Author: Anil Kumar Pandey      Member Level: Platinum      Member Rank: 1     Date: 09/Sep/2012   Rating: 2 out of 52 out of 5     Points: 4

You can try this sample code for remaining character in the text box.


<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load()
If NOT(Page.IsPostBack) Then
txtFeatures.Attributes("name") = "txtFeatures"
txtFeatures.Attributes("onKeyUp") = "textCounter(txtFeatures,remLen1,90);"
txtFeatures.Attributes("onKeyDown") = "textCounter(txtFeatures,remLen1,90);"
txtFeatures.Attributes("onKeyPress") = "textCounter(txtFeatures,remLen1,90);"
End If
End Sub
</script>

<head>
<script LANGUAGE="JavaScript">
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) {
field.value = field.value.substring(0, maxlimit);
}
else {
cntfield.value = maxlimit -
field.value.length;
}
}
</script>
</head>

<body>
<asp:TextBox ID="txtFeatures" runat="server" TextMode="MultiLine"
Columns="28" Rows="5" Wrap="true" />
<br />
<input readonly type="text" name="remLen1" id="remLen1" size="3"
maxlength="3" value="90" />
</body>


Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, DNS MVM



 
Post Reply
You must Sign In to post a response.

Next : Regular expression required
Previous : Method to Convert C# arraylist to javascript array
Return to Discussion Forum
Post New Message
Category:

Related Messages
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.