---
title: "How to refer html element in jquery validation in content page"  
description: "How to refer html element in jquery validation in content page"  
author: "Takeshi Okada"  
published: 2013-09-25  
updated: 2013-09-25  
canonical: https://www.mindstick.com/forum/1538/how-to-refer-html-element-in-jquery-validation-in-content-page  
category: "css-css3"  
tags: ["css-css3"]  
reading_time: 2 minutes  

---

# How to refer html element in jquery validation in content page

I have master and [content page](https://www.mindstick.com/blog/258/set-property-value-on-master-page-from-content-page) in asp .net [web application](https://www.mindstick.com/articles/13069/progressive-web-application-pwas-all-you-need-to-know-about). In my content page I am doing [jquery validation](https://www.mindstick.com/forum/158280/how-to-include-jquery-validation-in-a-web-page). I have [html](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript) element without runat="[server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over)" and I don't know how to refer to this id in jquery validation.

**Here is my HTML [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):**

```
<table>    <tr>        <td>            Title        </td>        <td>            <select id="nameTitle" runat="server" class="InputText">                <option value="-1">--Select--</option>                <option value="Mr.">Mr</option>                <option value="Mrs.">Mrs</option>                <option value="Miss.">Miss</option>            </select>        </td>    </tr>    <tr>        <td width="130px">            First Name:<span class="RedMainText"><sup>*</sup></span>        </td>        <td>            <input type="text" id="firstName" class="InputText" size="30" />        </td>    </tr>    <tr>        <td width="130px">            Surname:<span class="RedMainText"><sup>*</sup></span>        </td>        <td>            <input type="text" id="surname" class="InputText" size="30" />        </td>    </tr></table>
```

## Jquery validation:

```
rules:{    <%=nameTitle.UniqueID %>: { required: true },    firstName: { required: true },    surname: { required: true }},messages:{    <%=nameTitle.UniqueID %>: { required: "Title is required" },    firstName: { required: "First Name is required" },    surname: { required: "Surname is required" }}
```

Here [firstName](https://www.mindstick.com/interview/33973/how-to-split-the-full-name-into-firstname-and-lastname-in-sql-server) and lastName are not validated while nameTitle is validated. How to refer them? please advise.

## Replies

### Reply by Pravesh Singh

Hi Takeshi,

for writhing jquery-validate rules you should use name of elements not their ids!

## set name for your elements and then use the name:

```
<select name="nameOfTitle" id="nameTitle" runat="server"
class="InputText">           
<option value="-1">--Select--</option>           
<option value="Mr.">Mr</option>           
<option value="Mrs.">Mrs</option>           
<option value="Miss.">Miss</option></select>
```

## and in jquery validate use:

```
rules:{    nameOfTitle: { required: true },},messages:{    nameOfTitle: { required: "Title is required" },}
```

you should do the same for your other inputs as well.


---

Original Source: https://www.mindstick.com/forum/1538/how-to-refer-html-element-in-jquery-validation-in-content-page

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
