From 54e89937f972a24e872ac436aa587841f1961980 Mon Sep 17 00:00:00 2001 From: winwaed Date: Wed, 29 Jan 2014 20:20:57 -0600 Subject: [PATCH] Numeric validation for the colored foreground arc It is possible for the data value to include non-numeric characters. This happens explicitly with modifications such as: http://stackoverflow.com/questions/18955708/how-to-display-units-with-jquery-knob This modification works well for the label, but the addition of the '%' character causes the arc not to be displayed when the page is refreshed. The above fixes this and removes all non-number characters from the value before attempting to plot it. --- js/jquery.knob.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/jquery.knob.js b/js/jquery.knob.js index a2fb82a..ff555ab 100755 --- a/js/jquery.knob.js +++ b/js/jquery.knob.js @@ -153,6 +153,8 @@ this.v = this.$.val(); (this.v === '') && (this.v = this.o.min); + this.v = this.v.replace(/[^0-9.\-]/g, ''); + this.$.bind( 'change blur' , function () { @@ -763,4 +765,4 @@ ).parent(); }; -})(jQuery); \ No newline at end of file +})(jQuery);