TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 790
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 689
  • Total: 690
  • tino

Asking for some assistance with a script

Started by FERNSIDEâ„¢, August 09, 2008, 06:46:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

FERNSIDEâ„¢

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

Ianedres

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.

FERNSIDEâ„¢

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.

IchBin

You will probably have to do a preg_match of some time to search the string for a question mark.

FERNSIDEâ„¢

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 :)

bloc

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
}

Dragooon

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

This website is proudly hosted on Crocweb Cloud Website Hosting.