How do I compare specific characters in a Textbox?

0 favourites
  • 3 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • I'm creating a registration form for my game. Everything is set up and working great, users can create a username,email,password all of which is stored on my SQL database. I also have it set up so that the entered information is being checked in real time against my database to ensure no duplicate usernames or e-mails are trying to be registered. The only issue I'm having now is that people can register emails such as "A" or "asdasd" or whatever. Is there anyway to check that the text in the textbox contains a minimum of an "@" and a ".com"? So if the user enters an e-mail address that doesn't contain at least an "@" and a ".com" I can return false to disable the submit registration button?

  • So after much searching I came upon this amazing plugin for an Advanced Textbox object. It really is extremely helpful and suggest you give it a download if your project contains textbox object. Huge thanks to Pinco for this amazing help!

    Link to the plugin:

    Other than the normal textbox properties, this one provides also:

    PROPERTIES:

    • Background Color: allows you to pick a color for the background.
    • Transparent Background: allows you to disable the background color and have a transparent background.
    • Font: allows you to choose the font to use (like for the label).
    • Font Color: allows you to specify the font color.
    • Borders: allows to toggle the text box borders. If disabled it also remove the border highlight that certain browsers (like chrome) adds to the text input areas.
    • Top/Bottom/Left/Right Margin: allows to specify the distance in pixel that the text should keep from the margins.
    • Horizontal Alignment: allows you to customize the text alignment.
    • Select all on focus: if set to yes, when the textbox get the focus will select all the text inside.

    TRIGGERS:

    • On Focus Gain: triggered when the textbox has the focus.
    • On Focus Lost: triggered when the textbox lose the focus.

    CONDITIONS:

    • Has Focus: return true if the textbox has the focus.
    • Validate: return true if the textbox content is valid (based on the content type selected).

    ACTIONS:

    • Set Web Font: like for the text object, this allows to use webfonts on the textbox object.
    • Set Background Color: change the background color for the textbox object. It accepts the following color formats:
    • "rgb(0,0,0)": rgb function (remember to always use the quotes)
    • "#FFFFFF": hex color value (remember to always use the quotes)
    • "transparent": string color name
    • Toggle Borders: allows to enable/disable the textbox borders.
    • Scroll Top: scroll to the top line of the textarea.
    • Scroll Bottom: scroll to the bottom line of the textarea.
    • Select All: select the whole content of the textbox.
    • Append Text: append text at the end of the currently existing one.
    • Append New Line Text: append text at the end of the currently existing one in a new line.

    EXPRESSIONS:

    • TextAfter: Get the text after the caret text box's text.
    • TextBefore: Get the text before the caret text box's text.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You could also use tokencount and put as separator. If tokencount is less than 1 (or even 2 in event of email) it should be invalid.

    https://www.scirra.com/manual/126/system-expressions

    Maybe there is some even better condition here.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)