Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextField: New "placeholderText", "maxChars" and "restrictChars" options #59

Merged
merged 13 commits into from
Dec 16, 2016

Conversation

aW4KeNiNG
Copy link
Member

@aW4KeNiNG aW4KeNiNG commented Dec 16, 2016

  • placeholderText: A short hint that describes the expected value.
    The short hint is displayed in the textfield before the user enters a value.
    Use ":empty" css class to change the style.

  • maxChars: Maximum number of characters allowed in the textfield. By default -1 (unlimited chars).

  • restrictChars: Indicates the set of characters that an user can enter into the textfield.
    You can insert a range with the "-" character, or you can exclude with
    the "^" character.

    For example:

    • "a-z" : Allowed lowercase letters.

    • "a-zA-Z" : Allowed any letter.

    • "^Qq" : Allowed any char except "q" and "Q".

    • "a-z^q": Allowed lowercase letters except "q".

    • "0-9a-z": Allowed numbers and lowercase letters.

    • "0-9^4-6": Allowed numbers except 4, 5 and 6.

Example

<?xml version="1.0" encoding="utf-8"?>
<vbox id="main" width="100%" height="100%">
    <style source="../css/main.css" />

    <hbox width="100%">
        <label text="Default:"/>
        <textfield/>
    </hbox>

    <hbox width="100%">
        <label text="Placeholder text:"/>
        <textfield placeholderText="Insert text..."/>
    </hbox>

    <hbox width="100%">
        <label text="Max 10 Chars:"/>
        <textfield placeholderText="Insert text..." maxChars="10"/>
    </hbox>

    <hbox width="100%">
        <label text="Only Numbers:"/>
        <textfield placeholderText="Insert numbers..." restrictChars="0-9"/>
    </hbox>

    <hbox width="100%">
        <label text="Only 5 Numbers:"/>
        <textfield placeholderText="Insert numbers..." restrictChars="0-9" maxChars="5"/>
    </hbox>

    <hbox width="100%">
        <label text="Only lowercase:"/>
        <textfield placeholderText="Insert chars..." restrictChars="a-z"/>
    </hbox>

    <hbox width="100%">
        <label text="Only lowercase+numbers:"/>
        <textfield placeholderText="Insert chars..." restrictChars="a-z0-9"/>
    </hbox>

    <hbox width="100%">
        <label text="Only uppercase except Q:"/>
        <textfield placeholderText="Insert chars..." restrictChars="A-Z^Q"/>
    </hbox>

    <hbox width="100%">
        <label text="Any char except Q and q:"/>
        <textfield placeholderText="Insert chars..." restrictChars="^Qq"/>
    </hbox>

    <hbox width="100%">
        <label text="Only numbers except 4-7:"/>
        <textfield placeholderText="Insert chars..." restrictChars="0-9^4-7"/>
    </hbox>

</vbox>
#main {
    border: 1px solid #CCCCCC;
    padding: 10px;
}

.label {
	text-align: right;
    vertical-align: center;
    width: 200px;
}

.textfield {
    width: 100%;
}

image

Tests

@aW4KeNiNG aW4KeNiNG changed the title TextField: New "placeholderText", "maxChars" and "restrictChars" options WIP: TextField: New "placeholderText", "maxChars" and "restrictChars" options Dec 16, 2016
@aW4KeNiNG aW4KeNiNG changed the title WIP: TextField: New "placeholderText", "maxChars" and "restrictChars" options TextField: New "placeholderText", "maxChars" and "restrictChars" options Dec 16, 2016
@ianharrigan ianharrigan merged commit 139a8ab into master Dec 16, 2016
@ibilon ibilon deleted the textfieldFeatures branch December 16, 2016 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants