2011-08-23 62 views

回答

1

To Exactly quote a previous answer of mine:

這篇文章可以幫助你:

http://msdn.microsoft.com/en-us/library/aa479045.aspx

尤其是本節(尋找 「客戶端驗證」,然後在那裏, 「特效」):

<asp:Label id=lblZip runat=server 
    Text="Zip Code:"/> 
<asp:TextBox id=txtZip runat=server 
    OnChange="txtZipOnChange();" /></asp:TextBox><br> 
<asp:RegularExpressionValidator id=valZip runat=server 
    ControlToValidate=txtZip 
    ErrorMessage="Invalid Zip Code" 
    ValidationExpression="[0-9]{5}" /><br> 

<script language=javascript> 
function txtZipOnChange() { 
    // Do nothing if client validation is not active 
    if (typeof(Page_Validators) == "undefined") return; 
    // Change the color of the label 
    txtZip.style.color = valZip.isvalid ? "Black" : "Red"; 
} 
</script> 

還有一些接線需要完成,你可以用一些jQuery或l ike

+0

非常感謝:)! – Baconbeastnz