1

嗨,我在 Rails 上制作应用程序,

Ruby on Rails ..这就是我复制所有 HTML 的原因,因为我有一个疑问,因为 ids,像这样生成的,还有类和名称..

如果它是一个简单的 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}.")
});


  });
4

0 回答 0