Linebreaks do not seem to be being counted properly when using javascript length property

RESOLVED DUPLICATE of bug 188015

Status

()

Firefox
General
RESOLVED DUPLICATE of bug 188015
9 years ago
9 years ago

People

(Reporter: Bart Skondin, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

9 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5

Linebreaks do not seem to be being counted properly when using javascript length property. Running the following input through the example code below results in different length values when done in IE7 versus Firefox.

Environment: IE7 - 7.0.5730.13
	
	Input Scenario 1:

		1carriageReturnHere
		2

	Result:

		3

	Input Scenario 2:
	
		1carriageReturnHere
		2carriageReturnHere
		3

	Result:
	
		5
		
Environment: Firefox - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
	
	Input Scenario 1:

		1carriageReturnHere
		2

	Result:
	
		4

	Input Scenario 2:
	
		1carriageReturnHere
		2carriageReturnHere
		3

	Result:
	
		7

Function that displays the scenario:

function callMe(inputField) {

    var inputFieldVal = inputField.value;

    if( inputFieldVal.length > 0 ) {
    	alert('inputFieldVal is ' + inputFieldVal);
    	alert('inputFieldVal.length = ' + inputFieldVal.length);
    }
}

Reproducible: Always

Steps to Reproduce:
1. Enter text with linebreak such as:
 1carriageReturnHere
 2noCarriageReturn

2. Examine length with javascript function.
Actual Results:  
Received a length of 3.

Expected Results:  
I expected a length of 4.

For a quick test to see this bug in action in code other than my own, I used the following site for external validation. Same behavior witnessed.

http://www.javascriptkit.com/script/script2/charcount.shtml

Updated

9 years ago
Status: UNCONFIRMED → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 188015
You need to log in before you can comment on or make changes to this bug.