Browse Source

added validation to avoid the enter event on forms when reading barcode scanner

jose miguel 7 years ago
parent
commit
76161b2b21
2 changed files with 14 additions and 0 deletions
  1. 7 0
      app/views/products/_form.html.erb
  2. 7 0
      app/views/products/_form_remote.html.erb

+ 7 - 0
app/views/products/_form.html.erb

@@ -315,6 +315,13 @@
 		getVariants();
 		showPriceBaseInput(<%= @product.is_in_dollars? %>);
 
+		$(document).on("keydown", function (e) {
+			if (window.location.pathname == "/products/new") {
+				if (e.which === 8 && !$(e.target).is("input, textarea")) {
+					e.preventDefault();
+				}
+			}
+		});
 	});
 
 	$('#product_size_list').on('change', function(event) { getVariants(); });

+ 7 - 0
app/views/products/_form_remote.html.erb

@@ -341,6 +341,13 @@
 		getVariants();
 		showPriceBaseInput(<%= @product.is_in_dollars? %>);
 
+		$(document).on("keydown", function (e) {
+			if (window.location.pathname == "/purchases/new") {
+				if (e.which === 8 && !$(e.target).is("input, textarea")) {
+					e.preventDefault();
+				}
+			}
+		});
 	});
 
 	$("#submit_remote").on( "click", function(e) {