From 750482474f56e889d94714ffa8223d0daaa69364 Mon Sep 17 00:00:00 2001 From: James <james@sourcefabric-DX4840.(none)> Date: Tue, 13 Sep 2011 15:21:23 -0400 Subject: [PATCH] CC-2791: limiting length and numeric with javascript - done --- .../public/js/airtime/preferences/streamsetting.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js index 21bc50a88..a239dc0da 100644 --- a/airtime_mvc/public/js/airtime/preferences/streamsetting.js +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -50,6 +50,16 @@ function hideForShoutcast(ele){ restrictOggBitrate(ele, false) } +function validate(ele,evt) { + var theEvent = evt || window.event; + var key = theEvent.keyCode || theEvent.which; + if ((ele.val().length >= 5 || (key < 48 || key > 57)) && !(key == 8 || key == 9 || key == 13 || key == 37 || key == 39 || key == 46)) { + theEvent.returnValue = false; + if(theEvent.preventDefault) theEvent.preventDefault(); + } + } + + function showForIcecast(ele){ var div = ele.closest("div") div.find("#outputMountpoint-label").show() @@ -69,6 +79,10 @@ $(document).ready(function() { rebuildStreamURL($(this)) }) + $("input:[id$=-port]").keypress(function(e){ + validate($(this),e) + }) + $("select:[id$=-output]").change(function(){ rebuildStreamURL($(this)) })