Closed Bug 161046 Opened 23 years ago Closed 23 years ago

Error in the javascript of checking phone number

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 160531

People

(Reporter: mozillabug321, Assigned: jst)

References

()

Details

Attachments

(1 file)

They use the following code to validate a international phone number (+44 1234 567890). http://www.sonyericsson.com/uk/spg.jsp?page=start -> Configurators -> MMS Configurator -> Anything -> Enter phone number. If I enter +447787234234 (standard UK mobile telephone number), it will display "You must enter a valid phone number". However, if I enter +447787234235, it works. Any idea what is the problem of the following code? If I use Mozilla 1.0 Linux i686 20020623, it will work. Only not working on Mozilla 1.1b WinXP 2002072104. <!-- function checkForm(theForm) { var num = theForm.mobileNumber.value; var checkNum = '+' + parseFloat(num); if (num == '' || num.charAt(0) != '+' || num != checkNum) { alert('You must enter a valid phone number'); return false; } return true; }
Following number will not work on the test case: +447787234234 +447787111111 +441111111111 +441111111112 Following number work in the test case: +441111111113 +447787234235
BTW, IE 6 on my machine works fine.
Summary: Error in the javascript of checking phone number → Error in the javascript of checking phone number
Confirming bug with Mozilla trunk binary 20020725xx on WinNT. STEPS TO REPRODUCE 1. Save the above testcase locally (so the submit() doesn't make Bugzilla mad) 2. Try the string +441111111113 NO PROBLEM 3. Try the string +441111111111 BUG!!! From Mozilla > Tools > Web Development > JavaScript Debugger, where I stepped through the function checkForm() given above: num [string] "+441111111111" parseFloat(num) [double] 441111111110.: <<<------------------------- THIS IS THE PROBLEM! checkNum [string] "+441111111110.:" This is a duplicate of bug 160531. As in that bug, certain numbers are being corrupted in the browser with a '.:' getting added. As in the other bug, we see no such corruption in the standalone JS shell: js> var num = "+441111111111" js> num +441111111111 js> parseFloat(num); 441111111111 Therefore reassigning to DOM Level 0 before duping -
Assignee: rogerl → jst
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → DOM Level 0
Ever confirmed: true
QA Contact: pschwartau → desale
mozillabug@kitkit.net: thank you for this report; you will be cc'ed on the other bug so you can monitor its progress. When that bug is marked "Fixed", please re-check your test with a Mozilla build taken one day after the fix date. If your testcase still doesn't work, please re-open bug 160531 (not this one). *** This bug has been marked as a duplicate of 160531 ***
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: