From e918f3b29ae8c8fa242f570c94670778abb84fad Mon Sep 17 00:00:00 2001 From: James Date: Mon, 12 Sep 2011 13:57:26 -0400 Subject: [PATCH] CC-2791: "Port" should only allow numbers and 5 digits - fixed - fixed scrolling when errors --- airtime_mvc/application/forms/StreamSettingSubForm.php | 2 ++ airtime_mvc/public/js/airtime/preferences/streamsetting.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/forms/StreamSettingSubForm.php b/airtime_mvc/application/forms/StreamSettingSubForm.php index c50735cf9..5a3e37e65 100644 --- a/airtime_mvc/application/forms/StreamSettingSubForm.php +++ b/airtime_mvc/application/forms/StreamSettingSubForm.php @@ -93,6 +93,8 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{ $port = new Zend_Form_Element_Text('port'); $port->setLabel("Port") ->setValue(isset($setting[$prefix.'_port'])?$setting[$prefix.'_port']:"") + ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) + ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.'))) ->setDecorators(array('ViewHelper')); if($disable_all){ $port->setAttrib("disabled", "disabled"); diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js index 481032f56..21bc50a88 100644 --- a/airtime_mvc/public/js/airtime/preferences/streamsetting.js +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -2,8 +2,8 @@ function showErrorSections() { $(".errors").each(function(i){ if($(this).length > 0){ - $(this).closest("div").show(); - $(window).scrollTop($(this).position().top); + // -250 is due to static panel on the top + $(window).scrollTop($(this).closest("div").position().top-250); return false; } });