課程
/前端開發(fā)
/HTML/CSS
/初識(shí)HTML(5)+CSS(3)-升級(jí)版
怎么實(shí)現(xiàn)做用戶注冊(cè)時(shí)帶星號(hào)的選項(xiàng)必填
2016-08-10
源自:初識(shí)HTML(5)+CSS(3)-升級(jí)版 3-2
正在回答
<span stylee="color:red">*</span>
jsp頁面中經(jīng)常會(huì)用到,只需在add頁面中添加上要求即可。當(dāng)然如果使用html就更簡單了。直接寫一個(gè)*,用css設(shè)置為紅色,<span style="color:red">*</span>
同問?
先給input設(shè)置個(gè)ID 以u(píng)sername為例。 ,在用Javascript 代碼驗(yàn)證:
?window.onload=function(){
?????var?name=document.getElementById('username').value;//獲取輸入框input的值
????????if(name==‘’)//判斷值是否為空
????????{
????????????alert('用戶名不能為空');
????????}
qq_苦笑這荒誕的一切_0 提問者
直接寫一個(gè)*,用css設(shè)置為紅色
<span style="color:red">*</span>
舉個(gè)例子吧:<input type=”text” id=”telephone” ><input type=“button” onclick=“functioncheck1”value=“檢測”>如果要檢測它是否符合標(biāo)準(zhǔn),那我就會(huì)在頁面中導(dǎo)入js包然后寫一個(gè)<script> ? ? ? ? ? ?functioncheck1() ? ? ? ? ? ?{ ? ? ? ? ? ? ? ?varreg1 = /^1(5|3|8)\d{9}$/; ? ? ? ? ? ? ? ?varstr1 = document.getElementById("telephone").value; ? ? ? ? ? ? ? ?if(reg1.test(str1)== true) ? ? ? ? ? ? ? ?{ ? ? ? ? ? ? ? ? ? ?alert("手機(jī)號(hào)碼OK"); ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ?else ? ? ? ? ? ? ? ?{ ? ? ? ? ? ? ? ? ? ?alert("請(qǐng)重新輸入手機(jī)號(hào)碼"); ? ? ? ? ? ? ? ?} ? ? ? ? ? ?} ? </script>就可以驗(yàn)證到了!
設(shè)置輸入框的值不能為空
舉報(bào)
HTML(5)+CSS(3)基礎(chǔ)教程8小時(shí)帶領(lǐng)大家步步深入學(xué)習(xí)標(biāo)簽用法和意義
1 回答帶/ 符號(hào)和不帶的區(qū)別
3 回答問題小星星
4 回答設(shè)置屬性的引號(hào)必須存在嗎?
6 回答不明白這里的代碼前面填寫的是#號(hào)
4 回答關(guān)于屬性的值必須要加上引號(hào)嗎?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-08-10
<span stylee="color:red">*</span>
2016-08-10
jsp頁面中經(jīng)常會(huì)用到,只需在add頁面中添加上要求即可。當(dāng)然如果使用html就更簡單了。直接寫一個(gè)*,用css設(shè)置為紅色,<span style="color:red">*</span>
2016-08-10
同問?
2016-08-10
先給input設(shè)置個(gè)ID 以u(píng)sername為例。 ,在用Javascript 代碼驗(yàn)證:
?window.onload=function(){
?????var?name=document.getElementById('username').value;//獲取輸入框input的值
????????if(name==‘’)//判斷值是否為空
????????{
????????????alert('用戶名不能為空');
????????}
2016-08-10
直接寫一個(gè)*,用css設(shè)置為紅色
<span style="color:red">*</span>
2016-08-10
舉個(gè)例子吧:
<input type=”text” id=”telephone” >
<input type=“button” onclick=“functioncheck1”value=“檢測”>
如果要檢測它是否符合標(biāo)準(zhǔn),那我就會(huì)在頁面中導(dǎo)入js包然后寫一個(gè)
<script>
? ? ? ? ? ?functioncheck1()
? ? ? ? ? ?{
? ? ? ? ? ? ? ?varreg1 = /^1(5|3|8)\d{9}$/;
? ? ? ? ? ? ? ?varstr1 = document.getElementById("telephone").value;
? ? ? ? ? ? ? ?if(reg1.test(str1)== true)
? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ?alert("手機(jī)號(hào)碼OK");
? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?else
? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ?alert("請(qǐng)重新輸入手機(jī)號(hào)碼");
? ? ? ? ? ? ? ?}
? ? ? ? ? ?} ?
</script>
就可以驗(yàn)證到了!
2016-08-10
直接寫一個(gè)*,用css設(shè)置為紅色
<span style="color:red">*</span>
2016-08-10
設(shè)置輸入框的值不能為空