HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 10th, 2009, 02:18 AM
red_rose red_rose is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 3 red_rose User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 56 m 40 sec
Reputation Power: 0
JavaScript - Keypress function not working in mozilla

hi,
i got problem. my onKeyPress function work in IE but not in mozilla..
below is some my coding

<SCRIPT LANGUAGE="JavaScript">

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}


function ValidateNumeric(ev)
{
var keyCode = window.event.keyCode;
if ((ev.keyCode > 127 || ev.keyCode < 95) && (ev.keyCode > 93 || ev.keyCode < 65) && (ev.keyCode > 63 || ev.keyCode < 43) && (ev.keyCode > 41 || ev.keyCode < 40) && (ev.keyCode > 37 || ev.keyCode < 37) && (ev.keyCode > 32 || ev.keyCode < 1))
window.event.returnValue = false;
}

</SCRIPT>


<TEXTAREA id=textarea1 onkeydown="javascript:textCounter(this.form.komen,this.form.r emLen,500);" onkeyup="javascript:textCounter(this.form.komen,this.form.r emLen,500);" onKeyPress="ValidateNumeric(event)" style="WIDTH: 460px; HEIGHT: 195px" name=komen cols=49 rows=2 class=test></TEXTAREA>


can anyone help me how to solve this matter..or maybe anyone face same problem, can give opinion how to settle down this problem...plz..

thanks in advance...

Reply With Quote
  #2  
Old September 10th, 2009, 03:30 AM
phoenix1986's Avatar
phoenix1986 phoenix1986 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2009
Location: India
Posts: 316 phoenix1986 User rank is Second Lieutenant (5000 - 10000 Reputation Level)phoenix1986 User rank is Second Lieutenant (5000 - 10000 Reputation Level)phoenix1986 User rank is Second Lieutenant (5000 - 10000 Reputation Level)phoenix1986 User rank is Second Lieutenant (5000 - 10000 Reputation Level)phoenix1986 User rank is Second Lieutenant (5000 - 10000 Reputation Level)phoenix1986 User rank is Second Lieutenant (5000 - 10000 Reputation Level)phoenix1986 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 43 m 12 sec
Reputation Power: 76
Send a message via Yahoo to phoenix1986
Exclamation

hi
welcome to aspfree...

please put your code in the
code tags

or you can select your code part and click on the # button in the editor..

Code:

your code goes here.......


that would help you get a quicker response....
__________________
“Life may not be the party we hoped for, but while we are here we should sing, dance and be merry all the time......."

Reply With Quote
  #3  
Old September 10th, 2009, 11:38 AM
ChiefWigs1982's Avatar
ChiefWigs1982 ChiefWigs1982 is offline
Cunning Linguist
Click here for more information.
 
Join Date: Mar 2005
Location: I used to live at home, now I stay at the house
Posts: 3,530 ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)ChiefWigs1982 User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 50746 Folding Title: Beginner FolderFolding Points: 50746 Folding Title: Beginner FolderFolding Points: 50746 Folding Title: Beginner Folder
Time spent in forums: 1 Month 1 Week 4 Days 11 h 36 m 52 sec
Reputation Power: 397
I think you'd be better off scrapping the event listening, and use
something simpler like a RegEx to make sure no non-numeric values
get entered...
__________________
Support requests via PM will be ignored!
Route of Queue | The General FAQ Thread | HOW TO POST A QUESTION

Perfectly Impossible - is the eagerly awaited debut release from Jayne Sarah - please buy it - it's really good!


Reply With Quote
  #4  
Old September 10th, 2009, 07:15 PM
red_rose red_rose is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 3 red_rose User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 56 m 40 sec
Reputation Power: 0
hi aashishnakra....
sorry coz not do in proper..

here is my code

Code:
<SCRIPT LANGUAGE="JavaScript">

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}

function ValidateNumeric(ev)
{
   var keyCode = window.event.keyCode;
    if ((ev.keyCode > 127 || ev.keyCode < 95) && (ev.keyCode > 93 || ev.keyCode < 65) && (ev.keyCode > 63 || ev.keyCode < 43) && (ev.keyCode > 41 || ev.keyCode < 40) && (ev.keyCode > 37 || ev.keyCode < 37) && (ev.keyCode > 32 || ev.keyCode < 1))
	 window.event.returnValue = false;
}

</SCRIPT>

<TEXTAREA id=textarea1 onkeydown="javascript:textCounter(this.form.komen,this.form.r  emLen,500);" onkeyup="javascript:textCounter(this.form.komen,this.form.r  emLen,500);" onKeyPress="ValidateNumeric(event)" style="WIDTH: 460px; HEIGHT: 195px" name=komen cols=49  rows=2 class=test></TEXTAREA>

Reply With Quote
  #5  
Old September 17th, 2009, 06:05 AM
swetha19 swetha19 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 19 swetha19 User rank is Corporal (100 - 500 Reputation Level)swetha19 User rank is Corporal (100 - 500 Reputation Level)swetha19 User rank is Corporal (100 - 500 Reputation Level)swetha19 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 6 h 53 m 44 sec
Reputation Power: 0
onkeypress function works in mozilla. There are some other things that you need to fix in your code.

1) window.event does not work in firefox. Hence modify ValidateNumeric function as below.

if(window.event)
keyPressed = window.event.keyCode; //for IE
else
keyPressed = e.which; // others

Use keyPressed variable in your if condition to compare.


2) In the textarea html, there are spaces in between which is not allowed. Correct it. I think i should be the name of the field where you want to show the count.

javascript:textCounter(this.form.komen,this.form.r emLen,500);

Reply With Quote
  #6  
Old September 17th, 2009, 06:26 AM
swetha19 swetha19 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 19 swetha19 User rank is Corporal (100 - 500 Reputation Level)swetha19 User rank is Corporal (100 - 500 Reputation Level)swetha19 User rank is Corporal (100 - 500 Reputation Level)swetha19 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 6 h 53 m 44 sec
Reputation Power: 0
Also use
e.preventDefault();instead of window.event.returnValue = false;

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > JavaScript - Keypress function not working in mozilla


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek