Sign in to follow this  
Followers 0
madmorgan

validate a input text filed

8 posts in this topic

hello all,

ive built a encryption program but its all most finnished i just need to validate a input text filed to make sure that some text is entered i dont mide if it has numbers and text in the filed. I just need it to dectect the prsents of text or numbers in the filed i have looked in the help file but i cant see any thing.

thanks for the help

Share this post


Link to post
Share on other sites



If you could post some code, so we have an idea what we are working with, that'd be awesome.


#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites

madmorgan,

i just need to validate a input text filed to make sure that some text is entered

FileGetSize will tell you if the file contains any bytes if that is what you need.

Or if you are asking the user to enter text into an Input or Edit control, then GUICtrlRead(ControlID)will let you know that somethng has been entered.

I hope this helps - if not, can you please explain what you are trying to do a little more. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

hello all,

sorry for the worse message ever i have ever done.

i want to make sure the user has entered a word in to a text labe that i read in my script i just want to make sure they enter a key word and if they dont it says enter keyword

and here is my program ive built

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>
#include <crypt.au3>
#Include <File.au3>


Global $data

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Encpytion And Decrpytion Message Program", 546, 443, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 16, 40, 297, 385)
GUICtrlSetData(-1, "")
$Label1 = GUICtrlCreateLabel("Encpytion And Decrpytion Message Program.", 64, 8, 410, 24)
GUICtrlSetFont(-1, 12, 800, 4, "MS Reference Sans Serif")
$Group1 = GUICtrlCreateGroup("Encryption", 328, 40, 169, 121)
GUICtrlSetFont(-1, 10, 800, 0, "MS Reference Sans Serif")
$Button1 = GUICtrlCreateButton("Encode Message", 344, 72, 139, 25)
$Button2 = GUICtrlCreateButton("Message To File", 344, 112, 139, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Decrypytion", 328, 184, 201, 121)
GUICtrlSetFont(-1, 10, 800, 0, "MS Reference Sans Serif")
$Button3 = GUICtrlCreateButton("Open Coded Message", 344, 216, 171, 25)
$Button4 = GUICtrlCreateButton("Decode Message", 344, 256, 171, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input1 = GUICtrlCreateInput("", 360, 352, 121, 21)
$Label2 = GUICtrlCreateLabel("Password", 384, 320, 74, 20)
GUICtrlSetFont(-1, 10, 800, 4, "MS Reference Sans Serif")
$Button5 = GUICtrlCreateButton("Close", 384, 392, 75, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Reference Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button5
            Exit
        case $Button1
            ENCODE_MESSAGE()
        Case $Button2
            CODED_MESSAGE_FILE()
        Case $Button3
            READ_CODE_MESSGAE()
        Case $Button4
            DECODE_MESSAGE()
    EndSwitch
WEnd
;need to read $input to make sure keyword is entered befor it encrypts the message

Func DECODE_MESSAGE()
    $read3 = GUICtrlRead($Edit1)
    $password = GUICtrlRead($Input1)
    $text3 = BinaryToString(_Crypt_DecryptData($read3,$password,$CALG_RC4))
    GUICtrlSetData($Edit1, $text3)
EndFunc

Func READ_CODE_MESSGAE()
    $file2 = FileOpenDialog("Open Coded Message",@DesktopDir & "\","Text Files (*.txt)",1)
    $read = FileOpen($file2,0)
    $read2 = FileRead($read)
    GUICtrlSetData($Edit1, $read2)
    FileClose($read)
EndFunc

Func CODED_MESSAGE_FILE()
    $path = (@DesktopDir&"\CODE_MESSAGE.txt")
    If FileExists($path) Then
        ;true line
    Else
        _FileCreate($path)
    EndIf
    $text2 = GUICtrlRead($Edit1)
    $file = FileOpen($path,2)
    FileWrite($file, $text2)
    FileClose($file)
EndFunc

Func ENCODE_MESSAGE()
    $text = GUICtrlRead($Edit1)
    $password = GUICtrlRead($Input1)
    _Crypt_Startup()
    $data = _Crypt_EncryptData($text,$password,$CALG_RC4)
    _Crypt_Shutdown()
    GUICtrlSetData($Edit1,$data)
EndFunc

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

From what I understand, you are looking to make sure that the field was not empty: basically that they provided something (anything) as an encryption password.

If that's the case you can take advantage of AutoIt considering empty strings as 'False' values:

Func ENCODE_MESSAGE()
    $text = GUICtrlRead($Edit1)
    $password = GUICtrlRead($Input1)
        
    If Not $password then
        <Do something to bug them for a password>
    Else
        _Crypt_Startup()
        $data = _Crypt_EncryptData($text,$password,$CALG_RC4)
        _Crypt_Shutdown()
        GUICtrlSetData($Edit1,$data)
    EndIf
EndFunc

Edit: Had an extra ']' at the end, not really sure why...

Edited by Fulano

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites

madmorgan,

As I suggested, use GUICtrlRead somehting like this: :(

case $Button1
    If GUICtrlRead($Input1) = "" Then
        MsgBox(0,"Error", "Please enter a Password"
    Else
        ENCODE_MESSAGE()
    Endif

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

ah simple and quite effict.

thanks

Share this post


Link to post
Share on other sites

thanks all for your lovly information

ive completed my program now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0