我有这个函数可以附加到我的表单(这是一个模式窗口):
function appendAddressForm(name, line1, line2, phone, fax) {
$("#addressForm form").append(
"<div style='clear:both;text-align:left;padding:10;'>" +
"<fieldset style='width:70%;padding:5;float:left'>" +
"<ul class='ui-helper-clearfix'>" +
"<li class='ui-state-default ui-corner-all' title='Delete Address' id><span class='ui-icon ui-icon-minus'></span></li>" +
"</ul>" +
"<label for='addressName' style='width:100px'>Office Name</label>" +
"<input type='text' size='20' name='addressName' id='addressName' value='" + name + "' /> <br>" +
"<label for='addressOne' style='width:100px'>Address Line 1</label>" +
"<input type='text' size='40' name='addressOne' id='addressOne' value='" + line1 + "' /> <br>" +
"<label for='addressTwo' style='width:100px'>Address Line 2</label>" +
"<input type='text' size='40' name='addressTwo' id='addressTwo' value='" + line2 + "'/> <br>" +
"<label for='addressPhone' style='width:100px'>Phone</label>" +
"<input type='text' size='20' name='addressPhone' id='addressPhone' value='(P)" + phone + "' /> <br>" +
"<label for='addressFax' style='width:100px'>Fax</label>" +
"<input type='text' size='20' name='addressFax' id='addressFax' value='(F)" + fax + "' />" +
"</fieldset>" +
"</div>");
}
这就是我访问第一个字段集的方式
var addressName = $.trim($("#addressName").val());
var addressOne = $.trim($("#addressOne").val());
var addressTwo = $.trim($("#addressTwo").val());
var addressPhone = $.trim($("#addressPhone").val());
var addressFax = $.trim($("#addressFax").val());
if(addressName != "" && addressOne != "" && addressPhone != "(P)" && addressFax != "(F)")
{
我有 jQuery 和一个按钮。单击此按钮后,我必须附加一个包含此字段集的部分。我最多可以在表单中添加 6 个字段集。我的问题是,我只能获得第一个字段集的值。我也想验证所有其他字段集。如何从其他字段集中获取值?