> For the complete documentation index, see [llms.txt](https://jscula.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jscula.gitbook.io/docs/form/.hasvalue.md).

# .hasValue()

A boolean Jscula method which is used to check if an element has a value or not

### Using the <mark style="color:purple;">`hasValue()`</mark> Method in Input Fields

The <mark style="color:orange;">`hasValue()`</mark> method helps determine if an input field holds a significant value. Here's a rundown of its use cases:

* **Decimal Numbers**: A value like `0.5` returns `true`, whereas an empty string returns `false`.
* **Negative Values**: Entries such as `-1` return `true`. Yet, a string or numerical `0` returns `false`.
* **Input Types**: Applicable to radio buttons and checkboxes to check selection status.

#### Key Takeaways

* The <mark style="color:purple;">**`hasValue()`**</mark> method returns a boolean: `true` if the input has a value, `false` if not.
* It can be used across different input types and other elements that works with value attributes, making it versatile for data validation.

#### Example:

```javascript
$("#firstname-input").hasValue() // returns true or false
```

### Check if Form Elements Has values using `hasValue()`&#x20;

The `hasValue` method allows you to verify if multiple form elements contain valid values. Whether you have a form with drop-down menus, radio buttons, various input types, checkboxes, or other elements, you can easily test all of them at once for validity.

Example usage:

```javascript
$('#form > input, #country-dropdown, #gender-radio, .hobby-checkboxes*').hasValue();
```

This checks if the specified elements have values, streamlining validation.
