I am working on the JQuery loop on the textbox such that whenever the classname="xyz" then it needs to put datetime control there else the textbox needs to work as a regular textbox where I have set validations. I am having trouble looping through using Jquery .each. Can someone let me know if I am missing something.
<script>
$(".xyz").each(function () {
if ($(this).hasClass('xyz')) {
$(".xyz").datepicker();
}})
</script>
<asp:TextBox ID="txt" runat="server" CssClass="xyz"></asp:TextBox>
You don't need the second class selector. Inside the loop you are already targeting each element with the "xyz" class. So just use the "this" keyword to perform your operation.
<script>
$(".xyz").each(function () {
$(this).datepicker();
});
</script>
<asp:TextBox ID="txt" runat="server" CssClass="xyz"></asp:TextBox>