Print Page | Close Window

Problem validating textarea

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Rich Text Editor (RTE)
Forum Description: Support forum for the Web Wiz Rich Text Editor (RTE).
URL: https://forums.webwiz.net/forum_posts.asp?TID=17591
Printed Date: 28 March 2026 at 10:03am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Problem validating textarea
Posted By: yokoloko
Subject: Problem validating textarea
Date Posted: 20 December 2005 at 7:19am

Hello,

I want to see if there's any "real" content in the textarea before submitting, is there any way to do it ??

I tried this, but the textarea is returning some HTML code... =*(
if(document.form.textarea.replace(/^\s*|\s*$/g,"") == "")
{
     alert("Type a message!");
     return false;
}



Replies:
Posted By: WebWiz-Bruce
Date Posted: 20 December 2005 at 7:45am
Gecko based browsers place in a <br> for some reason when empty.

I use the following on this forum that may need to be adapted:-

//For Gecko Madis API (RTE)
if (document.frmAddMessage.message.value.indexOf('<br>') > -1 && document.frmAddMessage.message.value.length == 8) document.frmAddMessage.message.value = '';



-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: yokoloko
Date Posted: 20 December 2005 at 10:15am
document.frmAddMessage.message.value.length == 8
document.frmAddMessage.message.value.indexOf('<br>') > -1
 
GREAT ideia!! =)
Thanks!!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net