I have been using jQuery for a while and this makes no sense to me. Can anyone explain why this is happening? I have a hidden field , <asp:HiddenField ID="hidIsValid" runat="server" /> and I have this code assigning a value to it.
This took me hours to decide to try to change the way I set the value , and now it works , but it appears this is the wrong way:
$('#<%= hidIsValid.ClientID %>').val("true"); **This line never worked
$('#<%= hidIsValid.ClientID %>').val() = "true"; **this line does work
I comes from here , I took out a lot of the code ,this is just ot show the pertinent lines.
function fnValidateAttendees() {
// $('#<%= hidIsValid.ClientID %>').val("true"); **This line never worked
$('#<%= hidIsValid.ClientID %>').val() = "true";
$('.tFirstName, .tLastName').each(function () {
if (!($(this).val().match(/^[a-z -']+$/))) {
$('#<%= hidIsValid.ClientID %>').val("false"); //**this line works
}
});
$('.tPhoneNumber').each(function () {
if (!($(this).val().match(/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/))) {
$('#<%= hidIsValid.ClientID %>').val("false"); //**this line works
}
});
$('.tEmail').each(function () {
if (!($(this).val().match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/))) {
$('#<%= hidIsValid.ClientID %>').val("false"); //this line works
}
});
return true;
}
can someone make sense of this
How can you make out that this does not work..
Setting the value using .val() will not be reflected in the DOM immediately..
Maybe that’s the reason you feel its not working..
Also this does not make any sense..