#include <GUIConstantsEx.au3>
$Form = GUICreate("Form1", 633, 454, 192, 114)
$Inputuser = GUICtrlCreateInput("", 82, 90, 93, 20)
$Label = GUICtrlCreateLabel("", 186, 91, 160, 20)
$Inputpass = GUICtrlCreateInput("", 82, 120, 93, 20)
$ccccc = GUICtrlCreateButton("Check", 100, 150, 75, 25)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $Inputuser
InputCheck()
EndSelect
WEnd
Func InputCheck()
$user = GUICtrlRead($Inputuser)
If Not StringRegExp($user, "^[A-Za-z0-9]+$") Then
GUICtrlSetState($Inputuser, $GUI_FOCUS)
GUICtrlSetData($Label, "X 只允许输入英文字母和数字.")
GUICtrlSetColor($Label, 0xFF0000)
GUICtrlSetFont($Label, 9, 400, 0, "Tahoma")
Else
GUICtrlSetData($Label, "√ 输入正确.")
GUICtrlSetFont($Label, 9, 800, 0, "Tahoma")
GUICtrlSetColor($Label, 0x008000)
GUICtrlSetFont($Label, 9, 400, 0, "Tahoma")
EndIf
EndFunc ;==>InputCheck
|