From 3a66c0da726ec7e4f3a0406f3f6c82de3abcc359 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 20 Oct 2016 13:51:51 +0930 Subject: Fix #6864 automatically convert IPv6 input to lowercase 1) As the user leaves the field, or presses Save, onChange will fire and convert the input string to lowercase. This saves the user havng to even think about it. 2) Provide some extra text that describes the expected format, to avoid them getting just "Please match the requested format" (cherry picked from commit d461ff40e364fc0ecc003b9f673cbad7c6a08f2f) --- src/usr/local/www/classes/Form/IpAddress.class.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/usr/local') diff --git a/src/usr/local/www/classes/Form/IpAddress.class.php b/src/usr/local/www/classes/Form/IpAddress.class.php index 30792d7..2b61523 100644 --- a/src/usr/local/www/classes/Form/IpAddress.class.php +++ b/src/usr/local/www/classes/Form/IpAddress.class.php @@ -63,14 +63,19 @@ class Form_IpAddress extends Form_Input switch ($type) { case "BOTH": $this->_attributes['pattern'] = '[a-f0-9:.]*'; + $this->_attributes['title'] = 'An IPv4 address like 1.2.3.4 or an IPv6 address like 1:2a:3b:ffff::1 (use lowercase)'; + $this->_attributes['onChange'] = 'javascript:this.value=this.value.toLowerCase();'; break; case "V4": $this->_attributes['pattern'] = '[0-9.]*'; + $this->_attributes['title'] = 'An IPv4 address like 1.2.3.4'; break; case "V6": $this->_attributes['pattern'] = '[a-f0-9:]*'; + $this->_attributes['title'] = 'An IPv6 address like 1:2a:3b:ffff::1 (use lowercase)'; + $this->_attributes['onChange'] = 'javascript:this.value=this.value.toLowerCase();'; break; } } -- cgit v1.1