EmailForm Widget v7 - nodeGame/nodegame GitHub Wiki

  • status : complete
  • version : 7.x

Illustration

Illustration of the EmailForm widget

Introduction

EmailForm is a widget that displays standard text input for email with validation.

Main Options

  • email: An initial email set in the form.
  • showSubmitBtn: If TRUE, a submit button is added below the form. Default: TRUE. (dev version)
  • onsubmit: Options passed to getValues when the submit button is pressed. Default:
{ 
    emailOnly: true, 
    send: true, 
    updateUI: true 
}
  • setMsg: If TRUE, a SET message (automatically stored in the memory database of the logic) is sent. Default: a SAY message (requires a custom event listener on the recipient).

Main Texts Options

  • label: 'Enter your email:'
  • errString: 'Not a valid email address, please correct it and submit it again.',
  • sent: 'Sent!' (dev version)

Main methods

getValues(options): Returns the value held by the form. Configuration options:

  • emailOnly: If TRUE, returns just the email (see usecase). Default: FALSE.
  • verify: If TRUE, check if the email is valid. Default: TRUE.
  • reset: If TRUE, it resets after reading it. Default: FALSE.
  • markAttempt: If TRUE, wrong emails are added to the attempts array and returned (see usecase). Default: TRUE.
  • updateUI: If TRUE, the UI (form, input, button) is updated. Default: FALSE.
  • highlight: If TRUE, if email is not the valid, widget is is highlighted. Default: (updateUI || FALSE).
  • send: If TRUE, and the email is valid, then it sends a SAY or SET msg (see option setMsg). Default: FALSE.
  • sendAnyway: If TRUE, it sends a msg regardless of the validity of the email. Default: FALSE.
  • say: same as send, but deprecated.
  • sayAnyway: same as sendAnyway, but deprecated

Listeners

None.

Events

None.

Usecase

// Creates and append a new DoneButton widget.
var root = document.body;
var emailForm = node.widgets.append('EmailForm', root);

emailForm.getValues({ emailOnly: true }); 
// Returns:
// { value: [email protected] }

emailForm.getValues(); 
// Returns:
// { 
//     values: [email protected],
//     time:   123144354324,
//     attempts: [ 'not-an-email.com', 'again-not-an-email' ]
// }

Links

⚠️ **GitHub.com Fallback** ⚠️