diff --git a/app/views/settings/promotions/_form.html.erb b/app/views/settings/promotions/_form.html.erb index e90c8ef5..dc018ce3 100755 --- a/app/views/settings/promotions/_form.html.erb +++ b/app/views/settings/promotions/_form.html.erb @@ -142,7 +142,7 @@ <% end %>
<%= f.input :original_product,collection: sample %>
-
<%= f.input :min_qty ,label: "Qualified Qty", :input_html => {:style => 'height: 37px'} %>
+
<%= f.input :min_qty ,label: "Qualified Qty", :input_html => {:style => 'height: 37px', min: 1, step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this);"} %>

@@ -179,13 +179,13 @@
- <%= pro.input :min_qty , label: false, :input_html => {:style => 'height: 37px'}%> + <%= pro.input :min_qty , label: false, :input_html => {:style => 'height: 37px', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this);"}%>
- <%= pro.input :net_off , label: false, :input_html => {:style => 'height: 37px'} %> + <%= pro.input :net_off , label: false, :input_html => {:style => 'height: 37px', min: 1, step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this);"} %>
-
<%= pro.input :net_price , label: false, :input_html => {:style => 'height: 37px'} %>
-
<%= pro.input :percentage , label: false, :input_html => {:style => 'height: 37px'} %>
+
<%= pro.input :net_price , label: false, :input_html => {:style => 'height: 37px', min: 1, step: '1', :onkeypress => "return isNumberKey(event);"} %>
+
<%= pro.input :percentage , label: false, :input_html => {:style => 'height: 37px', min: 1, step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this);"} %>
<%= pro.link_to_remove "X" ,:class=>"btn-primary btn m-r-45", :style => 'width: 25px'%>
<% end %> @@ -432,5 +432,16 @@ $(document).on('turbolinks:load', function() { $('body').bootstrapMaterialDesign(); }); +function isNumberKey(evt) { + var charCode = (evt.which) ? evt.which : event.keyCode; + if (charCode > 31 && (charCode < 48 || charCode > 57)) { + return false; + } else { + return true; + } +} +function greaterThanOne(obj){ + if(parseInt(obj.value)<=0) $(obj).val(1); +}