電話號碼驗證
[.Net]
<asp:regularexpressionvalidator id=”Validphonenum” ControlToValidate=”phonenum” Display=”Static” ValidationExpression=”\(0\d{1}\)\d{4}\-\d{4}|\(0\d{1}\)\d{3}\-\d{5}|\(0\d{2}\)\d{3}\-\d{3}|\(0\d{3}\)\d{6}” runat=”server” ErrorMessage=”電話號碼格式有誤”>
[javascript]
if(NaN(txtphone.text))
{
alert();
return false;
}
========================================================
<script language=”javascript”>
function CheckForm(myForm)
{
var sHours=myForm.txtHours.value;
if(sHours==”")
{
alert (” 請填入課程時數”);
myForm.txtHours.focus();
}
else
{
if(isNaN(sHours))
{
alert(” 請填入課程時數為數值 “);
myForm.txtHours.focus();
return false;
}
}
}
</script>
<INPUT id=”txtHours” onblur=”CheckForm(document.forms[0])” type=”text” name=”txtHours” runat=”server”>
留言列表