sgds-forms

Validate SGDS form components with constraint and custom validation APIs.

18|10|Updated Aug 30, 2022
One-click install
npx skills add https://github.com/GovTechSG/sgds-web-component --skill sgds-forms
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sgds-forms
Source: https://github.com/GovTechSG/sgds-web-component/tree/main/skills/sgds-forms
Command: npx skills add https://github.com/GovTechSG/sgds-web-component --skill sgds-forms

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

SGDS form components require consistent validation feedback, submission handling, and FormData integration; this skill consolidates guidance and best practices for implementing, testing, and debugging SGDS form behavior.

Core Features & Use Cases

  • Handles hasFeedback-driven constraint validation and invalidFeedback customization for sgds-input, sgds-textarea, sgds-select, and related components.
  • Demonstrates how to read FormData from a form containing SGDS components and how to access file uploads via sgds-file-upload when needed.
  • Covers custom validation workflows using setInvalid and noValidate on individual components or novalidate on the form.

Quick Start

Wrap SGDS form components in a form element with a name attribute and enable hasFeedback to display validation messages.

Frequently Asked Questions about sgds-forms

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I validate SGDS form components and display feedback messages?

To validate SGDS form components, wrap sgds-* elements inside a form element with a name attribute and enable hasFeedback to display constraint validation messages automatically.

How do I read FormData from a form containing SGDS input components?

You can read FormData from an SGDS form by gathering submission data from sgds-input, sgds-textarea, and sgds-select components, and access file uploads separately via the sgds-file-upload component.

Can I set custom validation states on individual SGDS form fields?

Yes, you can set custom validation states on SGDS form fields by using the setInvalid API to control validity states and overriding invalidFeedback messages for individual components.

How do I disable native constraint validation for an SGDS form?

To disable native constraint validation for an SGDS form, apply noValidate on individual sgds-* components or add the novalidate attribute directly to the parent form element.

What is the best way to handle form submission with custom validation workflows in SGDS?

The best way to handle SGDS form submission with custom validation is combining the setInvalid API for programmatic validity overrides with noValidate to bypass native checks before gathering FormData.

Does SGDS form validation work with custom invalidFeedback overrides for textarea components?

Yes, SGDS form validation supports custom invalidFeedback overrides for sgds-textarea and other form components while using hasFeedback to maintain consistent validation feedback display.