I have a textbox and im trying to check if it has anything in, and if it doesnt i need to show a relevant error message but even when i have entered something in it, it continues to show the error message
Iv created a it here http://jsfiddle.net/Atkinson1988/SzuVQ/
var DiarisedReason = $("#txtDiarisedReason").val();
if (jQuery.trim(DiarisedReason).length < 0);
{
alert('Please Enter Diarised Notes');
return false;
}
Im not sure what im doing wrong?
Thank you for your time.
I suggest you to use RequiredFieldValidator in asp.net, as it provides easy way to validate the server side controls.
and for Required field validator
then check for
Page.IsValidin the page load event to submit the form.if you want javascript/jquery solution, then you can try like this
you can do with val() also. something like this .
!will check for the value in the textbox value.alternativiley, you can check for trimmed value also. by using trim()
check demo : JsFiddle