Devtools: Fix regex to show error for inputs which expects number
Before this change, latitude and longitude inputs in Geolocations and pixel ratio in Devices Settings which expects a number wasn't throwing error when invalid input was entered. E.g. An input starting with digits and ending with any non-digit character like 1.1a. This change uses Number.isNaN for validation instead of regex. Using this method is better instead of regex considering localization and also fixes the current bug. Before: !/^[\d]+(\.\d+)?|\.\d+$/.test(value) After: parsedValue = Number(value.trim()) Number.isNaN(parsedValue); Gif before the change: https://imgur.com/sFOBWfd Gif after the change: https://imgur.com/BiUll5C Bug: 990451 Change-Id: Id41ccee141ff36257505e451b7f44b950cb833a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1776594Reviewed-by:Yang Guo <yangguo@chromium.org> Commit-Queue: Chandani Shrestha <chshrest@microsoft.com> Cr-Commit-Position: refs/heads/master@{#702081}
Showing
Please register or sign in to comment