Hi..
How to validate an ASP.Net Textbox using javascript.It should not accept Empty Textbox and even it should not accept if we enter spaces in front with empty text should also not allow.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jul 25, 2012, 8:12 AM
try...
Java script function
function validateWholeText(obj) {
if (document.getElementById(obj.id).value == "") {
alert('Empty text is not allowed.');
obj.focus();
}
}
function ValidateTextbox(ID, keyCode) {
if (document.getElementById(ID).value == "" && keyCode == 32) {
return false;
}
}
text box defination
this will not accept space as first digit and also not allow empty text on lost focus.
hope this will help you.
rakesh chaudhariPosted Jul 25, 2012, 6:53 AM