---
title: "Uncaught TypeError: Cannot set property 'unobtrusive' of undefined"  
description: "Uncaught TypeError: Cannot set property 'unobtrusive' of undefined"  
author: "Anonymous User"  
published: 2017-12-16  
updated: 2017-12-16  
canonical: https://www.mindstick.com/forum/34405/uncaught-typeerror-cannot-set-property-unobtrusive-of-undefined  
category: "c#"  
tags: ["asp.net mvc", "mvc", "mvc4", "razor"]  
reading_time: 1 minute  

---

# Uncaught TypeError: Cannot set property 'unobtrusive' of undefined

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances),

I having a trouble when implementing [validation](https://www.mindstick.com/articles/12234/validation-using-data-annotation-using-entity-framework) [javascript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp) in my [razor view](https://www.mindstick.com/forum/155820/how-to-generate-textbox-control-using-htmlhelper-in-razor-view). Following [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) is thrown while we run the project.

![Uncaught TypeError: Cannot set property](https://www.mindstick.com/mindstickforums/726a9f3e-210a-47ec-b4cb-3920378681ed/images/ca801014-fe12-498c-95e8-f40853776d91.png)

Here is my code,

```
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>

<div class="col-md-6">
               <label for="name">Name</label>
               @Html.TextBoxFor(x => x.Name, new { @maxlength = 50, @autofocus = "autofocus", @class = "form-control", placeholder = "Name" })
               @Html.ValidationMessageFor(x => x.Name)
 </div>
```

Please give me the solution to remove this error and implement validation successfully.

## Replies

### Reply by Hemant Patel

Hi Sophie,

After analyzing your code, I saw you are using your javascript file in wrong way.

Please rearranged your javascript file in the following manner to accomplish your task,

```
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>

<div class="col-md-6">
               <label for="name">Name</label>
               @Html.TextBoxFor(x => x.Name, new { @maxlength = 50, @autofocus = "autofocus", @class = "form-control", placeholder = "Name" })
               @Html.ValidationMessageFor(x => x.Name)
 </div>
```

I Hope its informative for you...


---

Original Source: https://www.mindstick.com/forum/34405/uncaught-typeerror-cannot-set-property-unobtrusive-of-undefined

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
