Преглед на файлове

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

jose miguel преди 7 години
родител
ревизия
76161b2b21
променени са 2 файла, в които са добавени 14 реда и са изтрити 0 реда
  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) {