How to check for null,white spaces and new lines while validating for a textarea using jquery. If the textarea is empty and has only new lines or spaces should raise an alert
see http://api.jquery.com/jQuery.trim/
karim79
2010-04-05 11:13:00
New line validation doesnt hold good with this code.I had tried this before
Hulk
2010-04-05 11:23:59
From the API Docs: The $.trim() function removes all newlines, spaces (including non-breaking spaces), and tabs from the beginning and end of the supplied string
Keith Rousseau
2010-04-05 11:27:41
Strange...............
Hulk
2010-04-05 11:31:02
A:
To get the content of a textarea use $("#textareaid").val()
jQuerys helper function $.trim() will cut all whitespaces before and after the content.
Can can always validate a string on your own, for instance, like
for(var i=0;i < yourstring.length; i++){
if(yourstring.charCodeAt(i) == 13){
// do something with return character
}
}
Kind Regards
--Andy
jAndy
2010-04-05 11:18:08