改变输入框文字的颜色 提交后,改变错误信息框输入的文字颜色 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 change the style.color property <script>function mytest(){ document.all.test.style.color="red";}</script><input type="text" name="test" value="111"><input type="button" name="but" value="点击" onclick="mytest()"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title><script>function myFun(){ var txt = document.getElementById("txt"); //txt.value = msg; if ( txt.value.search("^/[0-9]+$/") != -1) { //alert("d"); return true; } else { //alert("e"); txt.style.backgroundColor = "red"; return false; }}</script></head><body>当文本框里输入的不是数字时,文本框变成红色<input type="text" id="txt"><input type="button" onClick="return myFun();" value="测试"></body></html>作了一个小例子,希望对你有帮助 提交数据 一个div上放置了一个checkbox,重叠在一起,如何处理单击事件 用js删除td的相同内容 求教啊 求助:jquery ui dialog无法挡住ie6下的select 问一些基本问题,好心人来回答一下吧 怎么样保证在表单中输入的字符只能是数字的,谢谢了,给分! 为什么总是出错,请帮我看一下错在那里?? 参数带%号怎么传递 谁能告诉我怎么知道用户按了ESC键 在javascript中我已经知道了一个数组的名字但是字符串 请问用JavaScript能实现模拟按键功能吗?
function mytest()
{
document.all.test.style.color="red";
}
</script><input type="text" name="test" value="111">
<input type="button" name="but" value="点击" onclick="mytest()">
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script>
function myFun()
{
var txt = document.getElementById("txt");
//txt.value = msg;
if ( txt.value.search("^/[0-9]+$/") != -1)
{
//alert("d");
return true;
}
else
{
//alert("e");
txt.style.backgroundColor = "red";
return false;
}
}
</script>
</head><body>
当文本框里输入的不是数字时,文本框变成红色
<input type="text" id="txt">
<input type="button" onClick="return myFun();" value="测试">
</body>
</html>
作了一个小例子,希望对你有帮助