{curl 6.0, 7.0 applet}
{curl-file-attributes character-encoding = "utf8"}
{applet manifest = "manifest.mcurl",
    {compiler-directives careful? = true}
}

{value
    let feedback:MessageDisplay = {MessageDisplay}
    let full-name:TextField = 
        {TextField
            width = 8cm,
            
            {validate-with {StringValidator min-chars = 3, max-chars = 25}, required?=true}
        }

    let user-age:TextField = 
        {TextField
            width = 1cm,
            
            {validate-with {NumericValidator min-allowable = 18, max-allowable = 40}, required? = true, message = "Users must be between 18 and 40"}
        }

    let address1:TextField = 
        {TextField
            width = 8cm,
           
            {validate-with {StringValidator min-chars = 3}}
        }
    let address2:TextField = 
        {TextField
            width = 8cm,
           
            {validate-with {StringValidator min-chars = 3}}
        }

    let zip-code:TextField = 
        {TextField
            width = 3cm,
            
            {validate-with ValidationPattern.us-zip-code}
        }   

    let home-phone:TextField = 
        {TextField
            width = 5cm,
          
            {validate-with ValidationPattern.us-phone-number, required?=true}
        }

    let email-address:TextField = 
        {TextField
            width = 5cm,
       
            {validate-with ValidationPattern.email-address, required? = true}
        }

    let enter-button:CommandButton = 
        {CommandButton
            label = "Enter",
            name = "e-button",
            {on Action do
                {popup-message
                    {VBox
                        "You entered:",
                        full-name.value,
                        address1.value,
                        address2.value,
                        zip-code.value,
                        home-phone.value,
                        email-address.value,
                        user-age.value   
                    }
                }
            }
        }

    {Dialog
        {Table
            columns = 2,
            "Name:", full-name,
            "Address: ", address1,
            "City, State: ", address2,
            "Zipcode: ", zip-code,
            "Phone: ", home-phone,
            "Email: ", email-address,
            "Age: ", user-age,
            enter-button,  feedback
        },
        message-display = feedback,
        {validate-with {DialogValidator}},
        {on vc:ValidationComplete at d:Dialog do
            set {d.get-by-name "e-button"}.enabled? = d.valid?
        }
    }
}


