Bugged jQuery Widget

by clawfire

HTML

<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<form>
<input type="number"/><br><br>
<input type="number"/><br><br>
<input type="number"/><br><br>
<input type="number"/><br><br>
</form>

JavaScript

/*
 *  Project: Sympass
 *  Description: Hide an input an make a spinner, synced with it
 *  Author: Thibault Milan <[email protected]>
 *  License: Copyright VA Consulting (c) 2012 - All Rights Reserved
 */

 $(function() {
    $.widget('sympass.visualSpinner', {
        /** default options */
        options: {
          nameSpace: 'sympassVisualSpinner',
          btnPlus: $('<button type="button">+</button>'),
          btnMinus: $('<button type="button">-</button>'),
          valueContainer: $('<span></span>'),
          min: 0,
          max: null,
          step: 1,
          textbefore: null,
          textafter: null,
          onError: function(errors) {
            var msg = '';
            $.each(errors, function(i, error) {
              msg += error+"\n";
          });
            alert(msg);
        }
    },
        /**
         * autoLoad data from data API and mix options
         */
        _getOptions: function (options) {
          options = $.extend({}, options, this.element.data());
          return options;
        },
        /**
         * the constructor
         */
         _create: function() {
            this.options = this._getOptions(this.options);
            this.options.btnPlus.addClass(this.options.nameSpace+'-add');
            this.options.btnMinus.addClass(this.options.nameSpace+'-substract');
            this.options.valueContainer.addClass(this.options.nameSpace+'-value')
                                        .val(this.element.val());
            if (typeof this.element.attr('min') != 'undefined')this.options.min = parseInt(this.element.attr('min'));
            if (typeof this.element.attr('max') != 'undefined')this.options.max = parseInt(this.element.attr('max'));
            if (typeof this.element.attr('step') != 'undefined')this.options.step = parseInt(this.element.attr('step'));
            if (this.element.val() === '' || !(this.options.min < this.element.val() <...