This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Javascript issues

Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am facing two problems while using javascript in my web application.

1.When using on Key Press event:

Sorry due to some issues with posting html and javascript code i am writing the event handler names with spaces :

In the above case the validateInput() is getting called and my alerts also gets prompted as per the conditions BUT STILL if i try to key in alphabets in the text field they are getting keyed in which is not the expected behavior.

So i tried the following property of event object "event.returnValue = false" (for false case).This worked.

So can anybody please explain me what was the issue with former, that is, simply returning false???

2.I have the following things in my html form:

Now i have written a function to feed in the value in Field 2 above dynamically when i click the "Populate" button using the Field 1 value.

In this i am facing the problem :
I have limited the maxlength of field to 10.
And the value being calculated on click of "populate" button is of length more than 10.So rather than only 10 characters to be shown of the value calculated , it is showing the whole value having length more than 10.This defeats my purpose.

So can anybody please explain me why it is behaving like this and how can i rectify this??

Posts: 67275
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's usually better to ask different questions in different topics. It keeps the replies easier to follow.

For you second question, maxLength will only limit the number of characters that a user can type into the field. It has no effect when assigning a value to the field under script control.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!