229989799 发表于 2016-12-22 09:54:57

求助。如何让input输入特殊符号然后就提示?(如图)



如何让input输入特殊符号然后就提示?

kk_lee69 发表于 2016-12-22 10:34:58

回复 1# 229989799


http://www.autoitx.com/forum.php?mod=viewthread&tid=9577&highlight=INPUT

229989799 发表于 2016-12-22 12:12:47

本帖最后由 229989799 于 2016-12-22 12:15 编辑

回复 2# kk_lee69


    if StringRegExp($1,'#') Then
这样写是可以的。。如果符号多了就不行了
    if StringRegExp($1,'~!@#$%^&*(){}:"?/\') Then
上面这句不行

Alam 发表于 2016-12-22 13:02:35

本帖最后由 Alam 于 2016-12-22 13:03 编辑

类似判断如下:MsgBox(0, '', _PcName())

Func _PcName()
        Local $str = '`~!@#$%^&*()=+_[]{}|;:.",<>/?' & Chr(39)
        Local $input = InputBox('设置机器名', '注意,不可使用以下特殊字符:' & @CRLF & @CRLF & $str, 'PC008')
        If @error <> 0 Then Return SetError(1, '', '用户操作取消')
        $input = StringRegExp($input, '.', 3)
        For $i = 0 To UBound($input) -1
                If StringInStr($str, $input[$i]) Then
                        MsgBox(16, '输入非法', '您输入了特殊字符: ' & $input[$i])
                        Return _PcName()
                EndIf
        Next
        Return $input
EndFunc

zghwelcome 发表于 2016-12-23 09:27:51

$str = ClipGet()
StringRegExp($str,'[~!@#$%^&*\(\){}\:"\?\/\\]+',1)
If Not @error Then MsgBox(0,0,"包含特殊字符")
页: [1]
查看完整版本: 求助。如何让input输入特殊符号然后就提示?(如图)