<commit_before><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>jQuery validation plug-in - dynamic forms demo</title>

<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />

<script src="../lib/jquery.js" type="text/javascript"></script>
<script src="../jquery.validate.js" type="text/javascript"></script>

<script type="text/javascript">
// only for demo purposes
$.validator.setDefaults({
	submitHandler: function() {
		alert("submitted!");
	}
});
$.validator.messages.max = jQuery.format("Your totals musn't exceed {0}!");

$.validator.addMethod("quantity", function(value, element) {
	return !this.optional(element) && !this.optional($(element).parent().prev().children("select")[0]);
}, "Please select both the item and its amount.");

$().ready(function() {
	$("#orderform").validate({
		errorPlacement: function(error, element) {
			error.appendTo( element.parent().next() );
		},
		highlight: function(element, errorClass) {
			$(element).addClass(errorClass).parent().prev().children("select").addClass(errorClass);
		}
	});
	
	var template = jQuery.format($("#template").val());
	function addRow() {
		$(template(i++)).appendTo("#orderitems tbody");
	}
	
	var i = 1;
	// start with one row
	addRow();
	// add more rows on click
	$("#add").click(addRow);
	
	// check keyup on quantity inputs to update totals field
	$("#orderform").delegate("keyup", "input.quantity", function(event) {
		var totals = 0;
		$("#orderitems input.quantity").each(function() {<commit_msg>Fixed delegate bug for dynamic-totals demo. Fixes #51<commit_after><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>jQuery validation plug-in - dynamic forms demo</title>

<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />

<script src="../lib/jquery.js" type="text/javascript"></script>
<script src="../jquery.validate.js" type="text/javascript"></script>

<script type="text/javascript">
// only for demo purposes
$.validator.setDefaults({
	submitHandler: function() {
		alert("submitted!");
	}
});
$.validator.messages.max = jQuery.format("Your totals musn't exceed {0}!");

$.validator.addMethod("quantity", function(value, element) {
	return !this.optional(element) && !this.optional($(element).parent().prev().children("select")[0]);
}, "Please select both the item and its amount.");

$().ready(function() {
	$("#orderform").validate({
		errorPlacement: function(error, element) {
			error.appendTo( element.parent().next() );
		},
		highlight: function(element, errorClass) {
			$(element).addClass(errorClass).parent().prev().children("select").addClass(errorClass);
		}
	});
	
	var template = jQuery.format($("#template").val());
	function addRow() {
		$(template(i++)).appendTo("#orderitems tbody");
	}
	
	var i = 1;
	// start with one row
	addRow();
	// add more rows on click
	$("#add").click(addRow);
	
	// check keyup on quantity inputs to update totals field
	$("#orderform").validateDelegate("input.quantity", "keyup", function(event) {
		var totals = 0;
		$("#orderitems input.quantity").each(function() {
{'fraction_non_alphanumeric': 0.2043638598647818, 'fraction_numerical': 0.00921942224953903, 'mean_word_length': 5.283783783783784, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6853188', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1006, 'n_words': 217}