Jquery代码:
<script>
$(document).ready(function() {
var ma = $("#qty").val();
var str = $("#reqid").val();
$("#myform").validate({
rules: {
issue_quant_str: {
max: ma
}
}
});
});
</script>
HTML:
<table>
<tr><td><?php echo $array['item_name']; ?></td>
<td><?php echo $array['quantity']; ?></td>
<input type="hidden" value="<?php echo $array['requisition_id']; ?>" id="reqid" />
<td>
<div id="maxdiv">
<input type="text" name="issue_quant_<?php echo $array ['requisition_id'];?>" value="<?php echo $array['quantity']; ?>" />
</div>
</td>
<input type="hidden" value="<?php echo $stock_qty; ?>" id="qty" />
<td><?php echo $stock_qty;?></td>
<td><input type="text" name="rem_<?php echo $array['requisition_id'];?>" required/></td>
</tr>
</table>
这里我希望var str值与issue_quant连接。我没有得到str值。任何人都可以帮助我..
答案 0 :(得分:1)
var rules = {};
rules['issue_quant_' + str] = {max:ma};
$("#myform").validate({
rules: rules
});
答案 1 :(得分:0)
尝试var str=$("#reqid").text();
如果您的reqid
存在于您的HTML代码中并且在