代码贴上:
<html>
<head>
<script type="text/javascript">
function sendSms() {
document.getElementById("firstP").innerHTML = "手机号码: <input type='text' size='11' maxlength='11' />   <input type='button' value='确认发送' onclick=''/>";
}
</script>
</head>
<body>
<p id="firstP">
<input type="button" value="发送短信" onclick="javascript:sendSms()" />
</p>
</body>
</html>我的目的是点击“发送短信”按钮后,显示“手机号码”输入框和“确认发送”按钮,然后点击“确认发送”按钮的时候,能检证“手机号码”输入框是不是空的,如果是空的就弹出提示框,但是这个脚本我不知道应该写在哪里。自己写了都没法运行。哪位大侠帮帮忙。
<html>
<head>
<script type="text/javascript">
function sendSms() {
document.getElementById("firstP").innerHTML = "手机号码: <input type='text' size='11' maxlength='11' />   <input type='button' value='确认发送' onclick=''/>";
}
</script>
</head>
<body>
<p id="firstP">
<input type="button" value="发送短信" onclick="javascript:sendSms()" />
</p>
</body>
</html>我的目的是点击“发送短信”按钮后,显示“手机号码”输入框和“确认发送”按钮,然后点击“确认发送”按钮的时候,能检证“手机号码”输入框是不是空的,如果是空的就弹出提示框,但是这个脚本我不知道应该写在哪里。自己写了都没法运行。哪位大侠帮帮忙。
<head>
<script type="text/javascript">
function sendSms() {
document.getElementById("firstP").innerHTML = "<form id='form'>手机号码: <input id='shouji' type='text' size='11' maxlength='11' />   <input type='button' value='确认发送' onclick='check()'/></form>";
}function check(){
if(document.getElementById('shouji').value){
document.getElementById('form').action = 'http://www.baidu.com';
document.getElementById('form').submit();
}else{
alert('手机不能为空')
}
}
</script>
</head>
<body>
<p id="firstP"></p><input type="button" value="发送短信" onclick="javascript:sendSms()" />
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function showSendBox() {
document.getElementById('sendBox').style.display = "block";
}
function send() {
var val = document.getElementById('phoneNumber').value;
if (val == "") {
alert('号码为空');
return;
}
else {
alert('发送');
}
}
</script>
</head>
<body>
<div id="sendBox" style="display:none">
手机号码:<input type="text" id="phoneNumber" /> <input type="button" value="确认发送" onclick="send()" />
</div>
<input type="button" value="发送短信" onclick="showSendBox()" />
</body>
</html>