You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/06/01 16:26:08 UTC

[incubator-trafficcontrol] 02/02: Improve latitude/longitude input field validation

This is an automated email from the ASF dual-hosted git repository.

mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit 5fa257f72bf40c0c5a04281615a633c09cf45b26
Author: Rawlin Peters <ra...@comcast.com>
AuthorDate: Wed May 30 13:30:33 2018 -0600

    Improve latitude/longitude input field validation
---
 .../modules/form/cacheGroup/form.cacheGroup.tpl.html       | 14 ++++++++------
 .../modules/form/coordinate/form.coordinate.tpl.html       | 14 ++++++++------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/traffic_portal/app/src/common/modules/form/cacheGroup/form.cacheGroup.tpl.html b/traffic_portal/app/src/common/modules/form/cacheGroup/form.cacheGroup.tpl.html
index 2928970..fb0aa1a 100644
--- a/traffic_portal/app/src/common/modules/form/cacheGroup/form.cacheGroup.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/cacheGroup/form.cacheGroup.tpl.html
@@ -85,18 +85,20 @@ under the License.
             <div class="form-group" ng-class="{'has-error': hasError(cacheGroupForm.latitude), 'has-feedback': hasError(cacheGroupForm.latitude)}">
                 <label class="control-label col-md-2 col-sm-2 col-xs-12">Geo Magnetic Latitude *</label>
                 <div class="col-md-10 col-sm-10 col-xs-12">
-                    <input name="latitude" type="number" class="form-control" ng-model="cacheGroup.latitude" ng-pattern="/^[-+]?[0-9]*\.?[0-9]+$/" required autofocus>
-                    <small class="input-error" ng-show="hasPropertyError(cacheGroupForm.latitude, 'required')">Required Coordinate</small>
-                    <small class="input-error" ng-show="hasPropertyError(cacheGroupForm.latitude, 'pattern')">Invalid Coordinate</small>
+                    <input name="latitude" type="number" class="form-control" ng-model="cacheGroup.latitude" ng-min="-90.0" ng-max="90.0" required autofocus>
+                    <small class="input-error" ng-show="hasPropertyError(cacheGroupForm.latitude, 'required')">Required latitude</small>
+                    <small class="input-error" ng-show="hasPropertyError(cacheGroupForm.latitude, 'min')">Invalid latitude. Must be between -90.0 and 90.0</small>
+                    <small class="input-error" ng-show="hasPropertyError(cacheGroupForm.latitude, 'max')">Invalid latitude. Must be between -90.0 and 90.0</small>
                     <span ng-show="hasError(cacheGroupForm.latitude)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                 </div>
             </div>
             <div class="form-group" ng-class="{'has-error': hasError(cacheGroupForm.longitude), 'has-feedback': hasError(cacheGroupForm.longitude)}">
                 <label class="control-label col-md-2 col-sm-2 col-xs-12">Geo Magnetic Longitude *</label>
                 <div class="col-md-10 col-sm-10 col-xs-12">
-                    <input name="longitude" type="number" class="form-control" ng-model="cacheGroup.longitude" ng-pattern="/^[-+]?[0-9]*\.?[0-9]+$/" required autofocus>
-                    <small class="input-error" ng-show="hasPropertyError(cacheGroupForm.longitude, 'required')">Required Coordinate</small>
-                    <small class="input-error" ng-show="hasPropertyError(cacheGroupForm.longitude, 'pattern')">Invalid Coordinate</small>
+                    <input name="longitude" type="number" class="form-control" ng-model="cacheGroup.longitude" ng-min="-180.0" ng-max="180.0" required autofocus>
+                    <small class="input-error" ng-show="hasPropertyError(cacheGroupForm.longitude, 'required')">Required longitude</small>
+                    <small class="input-error" ng-show="hasPropertyError(cacheGroupForm.longitude, 'min')">Invalid longitude. Must be between -180.0 and 180.0</small>
+                    <small class="input-error" ng-show="hasPropertyError(cacheGroupForm.longitude, 'max')">Invalid longitude. Must be between -180.0 and 180.0</small>
                     <span ng-show="hasError(cacheGroupForm.longitude)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                 </div>
             </div>
diff --git a/traffic_portal/app/src/common/modules/form/coordinate/form.coordinate.tpl.html b/traffic_portal/app/src/common/modules/form/coordinate/form.coordinate.tpl.html
index 03a2a62..7371baf 100644
--- a/traffic_portal/app/src/common/modules/form/coordinate/form.coordinate.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/coordinate/form.coordinate.tpl.html
@@ -41,18 +41,20 @@ under the License.
             <div class="form-group" ng-class="{'has-error': hasError(coordinateForm.latitude), 'has-feedback': hasError(coordinateForm.latitude)}">
                 <label class="control-label col-md-2 col-sm-2 col-xs-12">Geo Magnetic Latitude *</label>
                 <div class="col-md-10 col-sm-10 col-xs-12">
-                    <input name="latitude" type="number" class="form-control" ng-model="coordinate.latitude" ng-pattern="/^[-+]?[0-9]*\.?[0-9]+$/" required autofocus>
-                    <small class="input-error" ng-show="hasPropertyError(coordinateForm.latitude, 'required')">Required Coordinate</small>
-                    <small class="input-error" ng-show="hasPropertyError(coordinateForm.latitude, 'pattern')">Invalid Coordinate</small>
+                    <input name="latitude" type="number" class="form-control" ng-model="coordinate.latitude" ng-min="-90.0" ng-max="90.0" required autofocus>
+                    <small class="input-error" ng-show="hasPropertyError(coordinateForm.latitude, 'required')">Required latitude</small>
+                    <small class="input-error" ng-show="hasPropertyError(coordinateForm.latitude, 'min')">Invalid latitude. Must be between -90.0 and 90.0</small>
+                    <small class="input-error" ng-show="hasPropertyError(coordinateForm.latitude, 'max')">Invalid latitude. Must be between -90.0 and 90.0</small>
                     <span ng-show="hasError(coordinateForm.latitude)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                 </div>
             </div>
             <div class="form-group" ng-class="{'has-error': hasError(coordinateForm.longitude), 'has-feedback': hasError(coordinateForm.longitude)}">
                 <label class="control-label col-md-2 col-sm-2 col-xs-12">Geo Magnetic Longitude *</label>
                 <div class="col-md-10 col-sm-10 col-xs-12">
-                    <input name="longitude" type="number" class="form-control" ng-model="coordinate.longitude" ng-pattern="/^[-+]?[0-9]*\.?[0-9]+$/" required autofocus>
-                    <small class="input-error" ng-show="hasPropertyError(coordinateForm.longitude, 'required')">Required Coordinate</small>
-                    <small class="input-error" ng-show="hasPropertyError(coordinateForm.longitude, 'pattern')">Invalid Coordinate</small>
+                    <input name="longitude" type="number" class="form-control" ng-model="coordinate.longitude" ng-min="-180.0" ng-max="180.0" required autofocus>
+                    <small class="input-error" ng-show="hasPropertyError(coordinateForm.longitude, 'required')">Required longitude</small>
+                    <small class="input-error" ng-show="hasPropertyError(coordinateForm.longitude, 'min')">Invalid longitude. Must be between -180.0 and 180.0</small>
+                    <small class="input-error" ng-show="hasPropertyError(coordinateForm.longitude, 'max')">Invalid longitude. Must be between -180.0 and 180.0</small>
                     <span ng-show="hasError(coordinateForm.longitude)" class="form-control-feedback"><i class="fa fa-times"></i></span>
                 </div>
             </div>

-- 
To stop receiving notification emails like this one, please contact
mitchell852@apache.org.