: Discover Excellence

The Path To Discover Excellence.

Sunday, 17 February 2019


 Here is the example that has been used throughout

the chapter so far with some modifications:

1. The function is called check Length() rather than

checkUsername (). It can be used on any text input.

2. The event object is passed to the event listener.

The code includes fallbacks for IES-8(Chapter13

demonstrates using helper functions to do th is).

3. In order to determine which element the user

was interacting with , the function uses the event

object's target property (and for IES-8 it uses the

equivalent s rcEl ement property).

This function is now far more flexible than the

previous code you have seen in this chapter because:

1. It can be used to check the length of any text

input so long as that input is directly followed by an

empty element that can hold a feedback message

for the user. (There should not be space or carriage

returns between the two elements; otherwise, some

browsers mi ght return a whitespace node.)

2. The code will work with IES-8 because it tests

whether the browser supports the latest features (or

whether it needs to fall back to use older techniques).

No comments:

Post a comment