SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: Word existence
-
Aug 23, 2001, 14:01 #1
Word existence
How do I check if a certain word exists in a text box? For example, if I set the word to be found to "word1", if the text box is "This is word1", and alert would come up saying that "word1" was found.
-
Aug 23, 2001, 14:57 #2
- Join Date
- Oct 2000
- Location
- Nashvegas Baby!
- Posts
- 7,845
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
if (formname.elementname.value == "string")
should do it. Someone please let me know if that is incorrect.Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes
-
Aug 23, 2001, 15:04 #3
- Join Date
- Jul 2001
- Location
- UK
- Posts
- 407
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I think that checks to see if the text in the textbox is identical to
string.
To see if the word exists inside a string, I think you'll need something like indexOf().
Not sure about the syntax, but it's something like:
Code:if (formname.elementname.value.indexOf("string") != -1) { alert("string was found in textbox") }
Bookmarks