3
Contributors
6
Replies
25
Views
3 Years
Discussion Span
Last Post by Varunkrishna
1

Try this:

function validateEmptytextBox() {
    var inputField = document.getElementById("textArea1").value;
    inputField = inputField.replace(/^\s+/, '').replace(/\s+$/, '');
    if(inputField == ""){
        alert("please enter a value, textarea cannot be empty");
    }else{ 
        alert("Success");
    }

}
0

@GliderPilot
Thanks for your reply. Please have a look at my jsfiddle here. No luck it is still not working. What am I missing?

Thanks,
Varun Krishna. P

Edited by Varunkrishna

0

@GliderPilot,
Thanks for pointing out the mistake. I have a small doubt. what are those character(s) doing in the replace() ? Could you please point me somewhere, where I could get some information on those characters(s)/replace function. And why there are two replace () methods?

Thanks,
Varun Krishna. P

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.