在外部JavaScript文件中調用asp文本框控件在母版頁中不起作用。
對於如這是我在外部的js代碼文件document.getelementbyid在主頁面的內容頁面中無法在外部javascript中工作
function name_valid()
{
var a=document.getElementById("name_box");
if(a==null || a=="")
{
alert('Enter the name');
}
var b=document.getElementById("dob_box");
if(b==null || b=="")
{
alert('Enter the Date Of Birth');
}
}
內容頁: 內容佔位符(頭):
<script src="valid.js" type="text/javascript" language="javascript" ></script>
contentplaceholder1:
<asp:TextBox ID="name_box" runat="server" ></asp:TextBox>
<asp:Textbox Id="dob_box" runat="server"></asp:TextBox>
<asp:Button ID="submit_button" runat="server" Text="Submit" OnClientClick="name_valid()"/>
這裏的JavaScript執行要麼名稱文本框爲空或者輸入一些名字 請幫我解決這個問題
在你的javascript代碼中有一個錯誤,因爲變量'a'沒有被定義,只是讓你知道。 – 2012-01-09 19:32:05