Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a MVC RAZOR view with one DropDown list and a text box. These two (attributes) are not belonging to a particular model.

How can I set the mandatory validations for Text Box and drop down list?

I tried using

<script type=text/javascript>
$(document).ready(function () {
$(&input.#trackcodeid").validate();
});
</script>

trackcodeid is input element name.

I am getting the below error.

0x800a01b6 - Microsoft JScript runtime error: Object doesn't support property or method 'validate'



Can anyone tell where I am wrong.

Thank you in andvance.
Posted
Comments
SrivaniS 19-Aug-13 3:20am    
Hi Thank you.

I tried as below. not working anything wrong..?
@Html.TextBox("txtTrackCode" ,new { @class="required"} )

1 solution

give class to that textbox
new { @class = "required" }
try it will work
please mark if it worjks for you
 
Share this answer
 
Comments
Member 11149146 21-Nov-14 6:59am    
{@class="required"} is it client side validation or server side?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900