"Adam" wrote:
>
> Hello is there a function in ASP that can force a database
> result to automatically wrap at say.. 25 characters in
> length?
>
> Reason for this is because I have a database and people
> could go in and put a message like
>
> "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"
>
> and when it is displayed on the site it will make the layout
> all messed up.
If you really want to avoid displaying such messages, why not simply reject
them instead of inserting them into your DB? Warn the user that his message
will be rejected (or that it was not recorded due to the long string), and
leave it at that.
The easiest way to test for long unbroken strings is with a regular
expression. Try something like this:
JScript:
if (/\w{25}/.test(myVar)) ... //-- Reject string
VBScript
:
Dim rx
Set rx = New RegExp
rx.Pattern = "\w{25}"
If rx.Test(strMyValue) Then
... ' Reject the string
End If
VBScript RegExp Object:
http://msdn.microsoft.com/library/en...sobjregexp.asp
Regular Expression Syntax (applies to both VBScript and JScript):
http://msdn.microsoft.com/library/en...gexpsyntax.asp
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.