Trongate MX
Documentation

Help Improve Our Docs

If you’ve found an error, spotted something missing, or feel a section could be clearer or better explained, we’d love to hear from you. Your feedback helps keep the documentation accurate and useful for everyone.

Please report issues or suggest improvements on GitHub. Community input is invaluable in making the docs stronger.

Not comfortable with GitHub? No problem — you can also get in touch with us directly via our contact form. We welcome all feedback.

Regarding Form Attributes

While Trongate MX enhances form handling with dynamic features, it's important to understand how to leverage HTML5's built-in form validation attributes and other useful form properties. These attributes can improve user experience by providing immediate feedback before form submission.

Making Fields Required

To make specific fields required in your form, add the 'required' attribute to individual form elements:

Here's how to implement this using Trongate's helper functions:

For those who prefer working directly with HTML, here's how to achieve the same functionality:

Setting Input Lengths

You can control the minimum and maximum length of text input fields:

Using Trongate's form helper functions:

Here's the same implementation using straightforward HTML:

Numeric Input Ranges

For numeric inputs, you can specify acceptable minimum and maximum values:

Here's the implementation using Trongate's helper functions:

To achieve this using pure HTML, here's the equivalent code:

Autocomplete Settings

The autocomplete attribute controls whether browsers should offer to save and auto-fill form data. This can be particularly important for login forms and sensitive information:

First, let's look at how to implement this using Trongate's helper functions:

Here's how to achieve the same functionality using standard HTML:

Common Validation Attributes:

  • required: Field must be filled out before submission
  • minlength: Minimum number of characters for text input
  • maxlength: Maximum number of characters for text input
  • min: Minimum value for numeric inputs
  • max: Maximum value for numeric inputs
  • pattern: Regular expression pattern for validation

Autocomplete Values:

  • off: Suggests that browsers should not automatically enter or select a value for this field
  • new-password: Indicates this field is for a new password, helping password managers suggest strong passwords
  • email: Indicates this field expects an email address
  • tel: Indicates this field expects a telephone number

Summary

HTML form attributes and client-side validation provide an essential first line of defense against invalid data while improving user experience. While client-side validation enhances user experience, remember to always implement server-side validation for security. Each validation attribute serves a specific purpose, and using them appropriately helps create more user-friendly forms.

×