소스 검색

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) {