input type="text" maxlength="11" /這是控制最大輸入字?jǐn)?shù)至于不能少于11個字,需要在點擊保存按鈕時,通過.length來控制
創(chuàng)新互聯(lián)公司是一家專注于成都網(wǎng)站設(shè)計、成都網(wǎng)站制作、外貿(mào)網(wǎng)站建設(shè)與策劃設(shè)計,合浦網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)十載,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:合浦等地區(qū)。合浦做網(wǎng)站價格咨詢:18980820575
以下是只能輸入數(shù)字和小數(shù)點,并且小數(shù)點只能輸入一次
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Textbox1.KeyPress
If Char.IsDigit(e.KeyChar) or e.KeyChar = Chr(8) or e.KeyChar = "." Then
If e.KeyChar = "." And InStr(TextBox1.Text, ".") 0 Then
e.Handled = True
Else
e.Handled = False
End If
Else
e.Handled = True
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim s As String = TextBox1.Text
If Not ((Mid(s, Len(s), 1) = "0" And Mid(s, Len(s), 1) = "9") Or (Mid(s, Len(s), 1) = "A" And Mid(s, Len(s), 1) = "Z")) Then
s = Microsoft.VisualBasic.Left(s, Len(s) - 1)
TextBox1.Text = s
TextBox1.SelectionStart = Len(TextBox1.Text)
End If
End Sub