• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Javascript issues

 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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??



Thanks,
Jignesh
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic