# Validate location

As the name suggests, this condition is used to validate the active location of the user filling the form against a pre defined Geo-Fence. Learn more about <mark style="color:purple;">**Geo-Fence Field**</mark>

### What is the use case?

Whenever you want users to not submit the form if the active location is outside a predefined Geo-Fence area. Let's understand this with an example.&#x20;

#### Attendance use case

* A project is being conducted on ground. A geo-fence area is defined at the project location.
* Now the On-field construction workers come to work and they need to mark their attendance at the project location.&#x20;
* If the active location of the user is outside the defined geo-fence then the attendance shouldn't be marked and a proper message is shown to the user

This can be achieved using **Validate location.**&#x20;

### **Over which type of field is it applied?**

The user creating the form applies this condition over a location type of field.

<figure><img src="https://4216568905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mc6E3BSGr4i8kVdH38k%2Fuploads%2Ffxti5aDMbLEATbBXdvTh%2Fimage.png?alt=media&#x26;token=5fa15746-5191-472b-aa98-689c6be929f1" alt=""><figcaption></figcaption></figure>

The user clicks on **Select Fields** to get list of all location type of fields that exists in the form being created.

### How do I set the area for validation of location?

The area for validation is set using the **Geofence** type of field. The user sets the area perimeter using the [<mark style="color:purple;">Geofence field</mark>](https://docs.senpiper.com/form-builder/adding-fields-and-saving-a-form/building-forms#10.-geo-fence).

<figure><img src="https://4216568905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mc6E3BSGr4i8kVdH38k%2Fuploads%2Fb0itonULH5yWz9nHMiXG%2Fimage.png?alt=media&#x26;token=10b56a4f-606a-46c8-89c3-c8afe536e8d0" alt=""><figcaption></figcaption></figure>

### How do I set this up?

Let's understand it in steps:

1. Create a **Project details** form for recording the details of the project and set this form as a [<mark style="color:purple;">master form</mark>](https://docs.senpiper.com/form-builder/creating-forms/additional-form-settings/conditions/broken-reference).
2. In the **Project details** for&#x6D;**,** create a [<mark style="color:purple;">Geofence fiel</mark>](https://docs.senpiper.com/form-builder/adding-fields-and-saving-a-form/building-forms#10.-geo-fence)<mark style="color:purple;">d.</mark>
3. Create a submission with Construction site perimeter as a value for the Geofence field in the **Project details** for&#x6D;**.**
4. Create another form **Attendance** form with the Geofence field and a location field in it along with other required fields and [<mark style="color:purple;">set the Project details</mark> <mark style="color:purple;"></mark><mark style="color:purple;">**form**</mark> <mark style="color:purple;"></mark><mark style="color:purple;">as a master form</mark>](https://docs.senpiper.com/form-builder/creating-forms/additional-form-settings/conditions/broken-reference) to the **Attendance** form.
5. [<mark style="color:purple;">Map</mark>](https://docs.senpiper.com/form-builder/creating-forms/additional-form-settings/conditions/conditional-values-of-fields/master-mapping) the Geofence field of **Attendance** form with the Geofence field of the **Project details** form.&#x20;
6. While creating the submission for the **Attendance** for&#x6D;**,** the Geofence field of **Attendance** form will have the Geo fence field value which is there in the submission created for the **Project details form** ([<mark style="color:purple;">this form being the master form and geofence fields are mapped</mark>](https://docs.senpiper.com/form-builder/creating-forms/adding-fields-and-saving-a-form/creating-master-records)).
7. In the **Attendance** form, now we can set the condition **Validate location** on the location field and use the Geo fence field for deciding the area to be considered for location validation.

<figure><img src="https://4216568905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mc6E3BSGr4i8kVdH38k%2Fuploads%2F2ZhNtYfEsoij1yX1XaP8%2Fimage.png?alt=media&#x26;token=fcbaacb1-04fe-4b0a-a21e-9d7cf2e7d95c" alt=""><figcaption></figcaption></figure>

In the above image,&#x20;

1. **Location** is the field over which **Validate location logic** will be applied. So by our example, Location field of **Attendance form** will be this field.
2. **Copied Geo fence is the** Geofence field with which the location has to be validated. In our example, it is the Geo fence field of the **Attendance form** whose value is mapped with the Geo fence field of the **Project details** form.&#x20;
3. Error message that should be shown to the user filling up the form in case the location validation fails.

### Can I allow the user to submit the form even if the location validation fails?

Yes you can. While setting up the condition, **Validate location** the user can choose to allow the user filling up the form to create successful submission even if the validation fails.

<figure><img src="https://4216568905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mc6E3BSGr4i8kVdH38k%2Fuploads%2FKcFVSdV4MtYKxq7kCjpp%2Fimage.png?alt=media&#x26;token=f2dff036-fc63-4cb8-bc76-a1eaac558a61" alt=""><figcaption></figcaption></figure>

> The user can set some condition as well to implement **Validate location** using [<mark style="color:purple;">Enter validation condition</mark>](https://docs.senpiper.com/form-builder/creating-forms/additional-form-settings/append-values-to-a-field#what-is-the-use-case) input box shown in the below image.
>
> The user has to give the **error message** that should be shown in case the validation fails.

<figure><img src="https://4216568905-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mc6E3BSGr4i8kVdH38k%2Fuploads%2FkKYwFJsnjWG6z1C0yolT%2Fimage.png?alt=media&#x26;token=c342b62c-e856-46ce-859f-805129ae616c" alt=""><figcaption></figcaption></figure>
