0
問題:我有一個具有單選按鈕和文本框的窗體。我想要做的是在文本框爲空時顯示紅色邊框。我能夠做到的。但是,我希望在文本字段中輸入字符時,紅色邊框會消失。更改背景顏色的組文本框
目前,我有以下幾點:
function SubmitMe() {
if (document.SubmitIdea.Name.value=="") {
alert("Please enter your Name.")
document.SubmitIdea.Name.focus()
return false
}
if (document.SubmitIdea.Department.value=="") {
alert("Please enter your Department.")
document.SubmitIdea.Department.focus()
return false
}
if (document.SubmitIdea.Supervisor.value=="") {
alert("Please enter your Supervisor's Name")
document.SubmitIdea.Supervisor.focus()
return false
}
if (document.SubmitIdea.NomEmail.value=="") {
alert("Who enter your email address.")
document.SubmitIdea.NomEmail.focus()
return false
}
if (document.SubmitIdea.Phone.value=="") {
alert("Who enter your Phone Number")
document.SubmitIdea.Phone.focus()
return false
}
myOption = -1;
var anonymousContainer = document.getElementById('anonymousContainer');
var anonymousTextField = document.getElementById('anonymousTextField');
var anonymousInputs = document.getElementsByName('Anonymous');
for (i=0; i<SubmitIdea.Anonymous.length; i++) {
if (SubmitIdea.Anonymous[i].checked) {
myOption = i;
}
}
if (myOption == -1) {
alert("Do you wish to remain anonymous?");
anonymousContainer.className += 'borderedContainer';
return false;
}
if(document.getElementById("textarea1").value=="" && document.getElementById("textarea2").value=="" && document.getElementById("textarea3").value==""){
alert("Please provide a brief summary of your idea");
if(document.getElementById("textarea1").value=="") {
if(document.getElementById("textarea1").value==""){
anonymousTextField.className += 'borderedContainer';
return false;
}
else
anonymousTextField.className += 'borderedContainer1';
return false;
}
return false;
}
document.SubmitIdea.SubmitIdeaBtn.disabled = true
document.SubmitIdea.action = "Employee_Ideasp.cfm"
document.SubmitIdea.submit()
}
function Check(){
if(document.getElementById('NO').checked) {
anonymousContainer.className += 'borderedContainer1';
}else if(document.getElementById('YES').checked) {
anonymousContainer.className += 'borderedContainer1';
}
}
<div id="anonymousTextField">
<textarea name="reason" id="textarea1" cols="6" maxlength="500" class="ideas"
style="background-color: transparent; color:##000000; font-size:14px;"
onFocus="clearTxt(this)" onkeydown="limitTxtArea(this); cntTxt(this, 500, 'cnt');" onkeyup="limitTxtArea(this); cntTxt(this, 500, 'cnt');"></textarea></div>
它不會出現,當我在文本字段中輸入文本的工作。
謝謝
嗯,你正在啓動函數調用,似乎並不存在 –
@JordanS調用函數funcitons函數不存在?他們確實存在 –
不在您提供的代碼中。 –