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
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.
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.
You will probably have to do a preg_match of some time to search the string for a question mark.
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 :)
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
}
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