0

我知道您不能在<form>like中使用 onLoad 属性<form id"form" onload="javascript:test()">,您只能在<body>

我的问题是,是否有任何属性可以在表单加载时调用函数,或者是否有不同的方法来执行此操作?

编辑:

就像这样

<form jwcid="form">
<script>
function checkForChange() {
var approvalStatus = document.getElementById('licensingStatus').value;
if(approvalStatus == "Pass"){
    document.getElementById('licensingApprovalDate').setAttribute("validators", "validators:maxDateToday,required");
} else {
    document.getElementById('licensingApprovalDate').setAttribute("validators", "validators:maxDateToday");
}   
}
</script>
.....
4

2 回答 2

1

表单不使用外部数据来构建它们(主体可以加载图像,iframe 可以加载外部文档等)。

所以:

</form>
<script> /* The form has loaded. Do your stuff */ </script>
于 2012-08-24T13:49:44.453 回答
0

What do you mean with "form is loaded"? I think you mean "when the form is submited". The attribute is "onsubmit": <form id="form" onsubmit="javascript:test()">

Your funktion has to return either true or false whether the form shall be submitted or not.

于 2012-08-24T13:45:47.903 回答