Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Confirm Pass and gui text field help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
unknowngiver




PostPosted: Thu May 25, 2006 9:29 pm   Post subject: Confirm Pass and gui text field help

hey
after struggling for 2 hours i made this simple form..now i am trying to get it to check if
1. All the fields are Filled in [not empty
2. Password and password confirm equal eachother
3. Email adress has "@something.ext" ending

but i cant seem to figure it out
help is REALLY REALLY needed appreciated

here is the code
code:

module zenix_textfields
    import GUI, render, font_register
    export name_field, emailid_field, register_fields, new_user, new_pass, new_email
    var emailid_field, name_field, password_field, passwordconfirm_field : int % The Text Field IDs.
    var new_email, new_pass, new_user,conf_pass : string := ""
    const x_register := (maxx div 2) + 50
    % ------------------
    % UserName
    % ------------------
     
    procedure NameEntered (text : string)
        GUI.SetSelection (emailid_field, 0, 0)
        GUI.SetActive (emailid_field)
    end NameEntered
    % ------------------
    % Email Adress
    % ------------------
    procedure emailEntered (text : string)
        GUI.SetSelection (name_field, 0, 0)
        GUI.SetActive (name_field)
    end emailEntered

    % -----------------------------
    % Password & Confirm Password
    % -----------------------------
    procedure passwordEntered (text : string)
        GUI.SetSelection (password_field, 0, 0)
        GUI.SetActive (password_field)
    end passwordEntered

    procedure password2Entered (text : string)           % Confirm Password
        GUI.SetSelection (passwordconfirm_field, 0, 0)
        GUI.SetActive (passwordconfirm_field)
    end password2Entered
    % ------------------------
    % Fields for Registration
    % ------------------------

    procedure register_fields
        render.bg
       
        var registerButton := GUI.CreateButton (x_register - 50, 200, 200, "Register", GUI.Quit)
        name_field := GUI.CreateTextFieldFull (x_register, 400, 150, "",
            NameEntered, GUI.INDENT, 0, 0)

        emailid_field := GUI.CreateTextFieldFull (x_register, 370, 130, "",
            emailEntered, GUI.INDENT, 0, 0)

        password_field := GUI.CreateTextFieldFull (x_register, 340, 120, "",
            passwordEntered, GUI.INDENT, 0, 0)
        GUI.SetEchoChar (password_field, '*')

        passwordconfirm_field := GUI.CreateTextFieldFull (x_register, 310, 120, "",
            password2Entered, GUI.INDENT, 0, 0)
        GUI.SetEchoChar (passwordconfirm_field, '*')

        var nameLabel := GUI.CreateLabelFull (x_register - 50, 400, "User Name:", 0, 0,
            GUI.RIGHT, 0)
        var addressLabel := GUI.CreateLabelFull (x_register - 50, 370, "Email:", 0, 0,
            GUI.RIGHT, font_register)
        var passlabel := GUI.CreateLabelFull (x_register - 50, 340, "Password:", 0, 0,
            GUI.RIGHT, font_register)
        var pass2label := GUI.CreateLabelFull (x_register - 50, 310, " Confirm Password:", 0, 0,
            GUI.RIGHT, font_register)


        loop
            exit when GUI.ProcessEvent
        end loop
        % -------------------
        % Gets all the Input
        % -------------------
        new_user := GUI.GetText (name_field)
        new_pass := GUI.GetText (password_field)
        conf_pass := GUI.GetText (passwordconfirm_field)
        new_email := GUI.GetText (emailid_field)
       

    end register_fields
end zenix_textfields

Thanks
Sponsor
Sponsor
Sponsor
sponsor
unknowngiver




PostPosted: Fri May 26, 2006 9:25 am   Post subject: (No subject)

anyone Sad
i struggled till 3 Am last night but still cant get it to work Sad i was also trying to limit the input [to 20 digits/characters] but it dint work either Sad
help pleasee
unknowngiver




PostPosted: Fri May 26, 2006 10:53 am   Post subject: (No subject)

after 4 hours of struggling i got it to ask the user for the pass thing again if tehy dont equal eachother...but when the form shows up...it has the previous input in it...is there a way of clearing it up?
here is my code

code:

module zenix_textfields
    import GUI, render, font_register
    export name_field, emailid_field, register_fields, new_user, new_pass, new_email
    var emailid_field, name_field, password_field, passwordconfirm_field : int % The Text Field IDs.
    var new_email, new_pass, new_user, conf_pass : string := ""
    const x_register := (maxx div 2) + 50
    % ------------------
    % UserName
    % ------------------

    procedure NameEntered (text : string)
        GUI.SetSelection (emailid_field, 0, 0)
        GUI.SetActive (emailid_field)
    end NameEntered
    % ------------------
    % Email Adress
    % ------------------
    procedure emailEntered (text : string)
        GUI.SetSelection (name_field, 0, 0)
        GUI.SetActive (name_field)
    end emailEntered

    % -----------------------------
    % Password & Confirm Password
    % -----------------------------
    procedure passwordEntered (text : string)
        GUI.SetSelection (password_field, 0, 0)
        GUI.SetActive (password_field)
    end passwordEntered

    procedure password2Entered (text : string)           % Confirm Password
        GUI.SetSelection (passwordconfirm_field, 0, 0)
        GUI.SetActive (passwordconfirm_field)
    end password2Entered
    % ------------------------
    % Fields for Registration
    % ------------------------

    procedure register_fields
        loop
            render.bg

            var registerButton := GUI.CreateButton (x_register - 50, 200, 200, "Register", GUI.Quit)
            name_field := GUI.CreateTextFieldFull (x_register, 400, 150, "",
                NameEntered, GUI.INDENT, 0, 0)

            emailid_field := GUI.CreateTextFieldFull (x_register, 370, 130, "",
                emailEntered, GUI.INDENT, 0, 0)

            password_field := GUI.CreateTextFieldFull (x_register, 340, 120, "",
                passwordEntered, GUI.INDENT, 0, 0)
            GUI.SetEchoChar (password_field, '*')

            passwordconfirm_field := GUI.CreateTextFieldFull (x_register, 310, 120, "",
                password2Entered, GUI.INDENT, 0, 0)
            GUI.SetEchoChar (passwordconfirm_field, '*')

            var nameLabel := GUI.CreateLabelFull (x_register - 50, 400, "User Name:", 0, 0,
                GUI.RIGHT, 0)
            var addressLabel := GUI.CreateLabelFull (x_register - 50, 370, "Email:", 0, 0,
                GUI.RIGHT, font_register)
            var passlabel := GUI.CreateLabelFull (x_register - 50, 340, "Password:", 0, 0,
                GUI.RIGHT, font_register)
            var pass2label := GUI.CreateLabelFull (x_register - 50, 310, " Confirm Password:", 0, 0,
                GUI.RIGHT, font_register)


            loop
                exit when GUI.ProcessEvent
            end loop

            % -------------------
            % Gets all the Input
            % -------------------
            new_user := GUI.GetText (name_field)
            new_pass := GUI.GetText (password_field)
            conf_pass := GUI.GetText (passwordconfirm_field)
            new_email := GUI.GetText (emailid_field)



            if new_pass = conf_pass then

                exit
            else
                GUI.ResetQuit
            end if

        end loop
    end register_fields
end zenix_textfields

Thanks
jamonathin




PostPosted: Fri May 26, 2006 11:06 am   Post subject: (No subject)

Since your code is not runnable, i'll go through each step for ya.

1. If a field is empty, the value of the field will be "". What you can do is run through all of the fields and check if any of them are equal to "". If one is, add it to a list of empty fields, here's an example.

code:

import GUI
var field : array 1 .. 3 of int
var emptyFields : flexible array 1 .. 0 of string
proc blah (thing : string)
    GUI.SetSelection (field (1), 0, 0)
    GUI.SetActive (field (1))
end blah
proc doneProc
    for i : 1 .. upper (field)
        if GUI.GetText (field (i)) = "" then %If = nothing
            new emptyFields, upper (emptyFields) + 1 %new field
            emptyFields (upper (emptyFields)) := "Field " + intstr (i) %storing
            put emptyFields (upper (emptyFields)) %displaying
        end if
    end for
    GUI.Quit
end doneProc
var done : int := GUI.CreateButton (300, 150, 1, "Done", doneProc)
for i : 1 .. upper (field)
    field (i) := GUI.CreateTextField (100, 200 - (i * 30), 100, "", blah)
end for
loop
    exit when GUI.ProcessEvent
end loop


That example simply stores the name if the field so it can be displayed. It can be changed around so that it suits the appropriate name.

2. You need to store the value of the password as he types it (maybe open in a new window so that ONLY that field is being used),then go from there

3. use a for loop with some string manipulation.

such as . .
[syntax="turing-ish pseudo"]
for i: 1 .. length(email)
if email(i) = "@" and has not had a "." before then
email = ok
end if
end for[/syntax]

Good luck, i'd expand more but i gotta run.
unknowngiver




PostPosted: Fri May 26, 2006 3:59 pm   Post subject: (No subject)

ahan
nice code..but if a field is empty..how do i get it to RESTART the form process...so it tells u 2 input something in there...
jamonathin




PostPosted: Fri May 26, 2006 9:02 pm   Post subject: (No subject)

Well what im doing in that code is displaying the empty fields then exiting the loop. What I would do in this situation is open a new window, tell the user which fields are empty then return to the main screen. Take a quick look at this program, its not source code but it's what im talking about.

http://compsci.ca/v2/viewtopic.php?t=11996
jamonathin




PostPosted: Fri May 26, 2006 9:05 pm   Post subject: (No subject)

What i also ment to add in was just go File -> Save, it'll show exactly what I mean.
unknowngiver




PostPosted: Mon May 29, 2006 9:27 am   Post subject: (No subject)

i still dont get it :'(
can anyone please add me on msn and help me out
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Mon May 29, 2006 9:42 am   Post subject: (No subject)

unknowngiver wrote:
ahan
nice code..but if a field is empty..how do i get it to RESTART the form process...so it tells u 2 input something in there...

ok, you see jamonathin's code right? its pretty excellent code, to deactivate the exiting of the "form process", just remove the "GUI.Quit" from the doneProc... it should make logical sense eh?
unknowngiver




PostPosted: Mon May 29, 2006 10:56 am   Post subject: (No subject)

yaiii it worked Very Happy
Now I need to make them blank after the registration..because if they click the REGISTER button again...the page has all the stuff that they had before [its not clearing it..]
MysticVegeta




PostPosted: Mon May 29, 2006 1:03 pm   Post subject: (No subject)

F10 and
code:
GUI.SetText

Look that up it has 2 args, (widgetID : int, text : string) the widgetID is the widget id duh. and the text would be "" (empty string) to blank-en (?) them.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: