> For the complete documentation index, see [llms.txt](https://docs.wirebootstrap.com/wirebootstrap/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wirebootstrap.com/wirebootstrap/reference/wire.ui/wire.ui.validate.md).

# wire.ui.validate

Validate multiple HTML elements on a page using the `wire.ui.validate` method.  This method will apply the validation configuration UI changes to the elements that fail validation.  It was return `true` if all the elements pass validation and `false` if at least one does not.

This method uses the [wire.validate](https://docs.wirebootstrap.com/wirebootstrap/reference/wire/wire.ui.validate) method for each element's validation.

## Parameters

| element | The root element for which descendant elements will be validated. |
| ------- | ----------------------------------------------------------------- |
| config  | The configuration for the validation.                             |

## Config Properties

Use the following properties on the second parameter `config` to configure the validation.

| Name     | Description                                                                                                                                                                                                                                                                                                        |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| css      | The CSS class to be added to each element that fails validation.                                                                                                                                                                                                                                                   |
| elements | The object containing the configuration to be applied to each element.  The configuration is the same as the one used in [wire.validate](https://docs.wirebootstrap.com/wirebootstrap/reference/wire/wire.ui.validate).  The name of each property should be the HTML element Id for each element to be validated. |

## Example

The following example validates three HTML elements.  All three are required.  `user-phone` needs to be a valid phone number and `user-email` needs to be a valid email address.  If any of these conditions fail, the `validate` method will return `false`.  The CSS class `invalid` will be added to any elements that fail validation.

```javascript
const valid = wire.ui.validate(document, {
    css: "invalid",
    elements: {
        'user-name': { required: true },
        'user-phone': { required: true, type: "phone" },
        'user-email': { required: true, type: "email" }
    }
});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wirebootstrap.com/wirebootstrap/reference/wire.ui/wire.ui.validate.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
