0

ユーザーが何かを入力する必要があるダイアログボックスに特殊文字を入力できないようにする必要があるという要件があります。数字と文字だけを許可したい。可能か不可能か誰か教えてくれませんか??

コードは次のようになります。

display dialog "Enter You Name: " default answer "Name" buttons{"Proceed"}

デフォルトの回答の場所では、ユーザーは特殊文字を入力しないでください.そうすることで彼を制限できますか??

4

1 に答える 1

3

次のようなことを試すことができます:

set allowedLetters to characters of (do shell script "printf \"%c\" {a..z}")
set allowedNumbers to characters of (do shell script "printf \"%c\" {0..9}")
set allowedAll to allowedLetters & allowedNumbers & space

repeat
    set response to text returned of (display dialog "Enter You Name: " default answer "Name" buttons {"Proceed"} default button 1)
    try
        repeat with aCharacter in response
            if (aCharacter as text) is not in allowedAll then
                display dialog "Please enter letters and numbers only" buttons {"OK"} cancel button 1 default button 1
            end if
        end repeat
        exit repeat
    end try
end repeat

return response
于 2013-07-17T13:54:27.240 に答える