TinyPortal

Development => Support => Topic started by: FERNSIDEâ„¢ on August 09, 2008, 06:46:49 AM

Title: Asking for some assistance with a script
Post by: FERNSIDEâ„¢ on August 09, 2008, 06:46:49 AM
My apologies if this is in the wrong section, or even if this shouldnt be asked here, as it has nothing to do with TP.
Its just Me asking for a little assistance  :)  And feel free to remove it. :)

Im playing with some js, and Im in need of some assistance.

Im looking to make an alert, for when a  "Question mark"  hasnt been entered into the form.

So if there is a sentence like
You would climb a mountain with a beer in hand

But since there is no "Question mark"  a reply would be..
Are you asking me, or telling me?

Ive got a popup to appear when there is no text
if (document.input1.textfield.value == "") {
alert("You havent entered any text")
return
}


but this is where Im stuck. :(

If it is not too much bother, could somebody please help a beginner out :)

Thank You in advance
Title: Re: Asking for some assistance with a script
Post by: Ianedres on August 09, 2008, 09:42:33 AM
I would assume you would place the text you are checking in the double quotes after the double equal signs; you could use "?" for a question with an alert, or "" for an empty field with another alert box stating as such.

Javascript is *not* my forte' but try that and see if that will assist you further.
Title: Re: Asking for some assistance with a script
Post by: FERNSIDEâ„¢ on August 09, 2008, 09:55:00 AM
Hi buddy, cheers for your reply :)
Thats the only other thing I have tried so far.
Sorry, I forgot to mention.

It makes any sentence with a Question mark set off the alert.
Reverse of what Im trying to achieve.
Title: Re: Asking for some assistance with a script
Post by: IchBin on August 10, 2008, 02:28:40 AM
You will probably have to do a preg_match of some time to search the string for a question mark.
Title: Re: Asking for some assistance with a script
Post by: FERNSIDEâ„¢ on August 11, 2008, 10:36:14 AM
Thanks for that ICH..
I did a little read up on that, as I'd never heard of it, and tried a few things.
No glory.
Its not a major thing, was merely an added feature, so Im gonna let it slip away for awhile.

Thanks guys for your assistance :)
Title: Re: Asking for some assistance with a script
Post by: bloc on August 12, 2008, 09:33:58 AM
I am not so fluid either, but try:


var str = document.input1.textfield.value;
if ( str.match("?")== "") {
alert("You havent entered a question sign!")
return
}
Title: Re: Asking for some assistance with a script
Post by: Dragooon on August 12, 2008, 10:05:44 AM
Maybe this
var str = document.input1.textfield.value;
if ( str.match("?") == null) {
alert("You havent entered a question sign!");
return;
}

Note : Added missing semi-columns