你好我在Rails上制作应用程序,
Ruby on Rails ..这就是为什么我复制了所有的HTML,因为有一个疑问,我有它因为id,生成的那样,类和名称..
如果它是一个简单的HMTL,我不会有这种疑惑,对不起,如果它不是一个简单的HTML,但这就是我为什么要这样做的问题,
但我的问题是使用jquery的验证。我有一个代码,为用户插入一行“成就”,他可以添加他想要的内容。
问题在于我需要强迫他们选择“俱乐部”或“国家队”
问题是我会有多个ID,因为添加的每个项目都会有一个新的ID ..
我怎样才能做到这一点..
这是一个小提琴http://jsfiddle.net/wt57R/2/
这是我的代码。
$(document).ready(function(){
// validate signup form on keyup and submit
$(".edit_player").validate({ // initialize the plugin
errorElement: 'div'});
$("#name").rules("add", { required: true, messages: { required: "<%= t('generales.camporequerido') %>"}});
$("#email").rules("add", { required: true, maxlength: 280, });
jQuery.extend(jQuery.validator.messages, {
required: "<%= t('generales.camporequerido') %>",
remote: "Please fix this field.",
email: "Ingresa un correo electrónico válido.",
url: "Please enter a valid URL.",
date: "Please enter a valid date.",
dateISO: "Please enter a valid date (ISO).",
number: "Please enter a valid number.",
digits: "Please enter only digits.",
creditcard: "Please enter a valid credit card number.",
equalTo: "Please enter the same value again.",
accept: "Please enter a value with a valid extension.",
maxlength: jQuery.validator.format("Please enter no more than {0} characters."),
minlength: jQuery.validator.format("Please enter at least {0} characters."),
rangelength: jQuery.validator.format("Please enter a value between {0} and {1} characters long."),
range: jQuery.validator.format("Please enter a value between {0} and {1}."),
max: jQuery.validator.format("Please enter a value less than or equal to {0}."),
min: jQuery.validator.format("Please enter a value greater than or equal to {0}.")
});
});