JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old September 23rd, 2006, 07:25 AM
captinmorgn captinmorgn is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 1 captinmorgn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 25 sec
Reputation Power: 0
Onblur help, please

Hi, All!

Can this be done? I am using this 'boilerplate' script attached to validate a form. It currently gives a pop up if certain words are used (onblur). I would also like the script to redirect the user to another page if any of those words are used.

Am I being clear?

Thanks For Any Help!
Joe
Attached Files
File Type: txt boilerplate.txt (1.7 KB, 97 views)

Reply With Quote
  #2  
Old September 25th, 2006, 04:19 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 471 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 9 m 44 sec
Reputation Power: 3
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
solution

this should do it...

Code:

<textarea name="Comments" rows="5" cols="70" onBlur = "this.value = checkForProfanity(this.value);">

 
<SCRIPT LANGUAGE = "JavaScript">
<!--
var numberOfWords = 32;
var message = "Please read the submission guidelines again! We cannot accept your site at this time.";
var isProfane = new makeArray(numberOfWords);
var word = new makeArray(numberOfWords);
 
function checkForProfanity(usersInput) {
 
var temp = usersInput;
temp = temp.toLowerCase(); 

word[1] = "cialis";
word[2] = "viagra";
word[3] = "penis";
word[4] = "valium";
word[5] = "enlargement";
word[6] = "pharmacy";
word[7] = "hoodia";
word[8] = "phentermine";
word[9] = "badword9";
word[10] = "badword10";
word[11] = "badword11";
word[12] = "badword12";
word[13] = "badword13";
word[14] = "badword14";
word[15] = "badword15";
word[16] = "badword16";
word[17] = "badword17";
word[18] = "badword18";
word[19] = "badword19";
word[20] = "badword20";
word[21] = "badword21";
word[22] = "badword22";
word[23] = "badword23";
word[24] = "badword24";
word[25] = "badword25";
word[26] = "badword26";
word[27] = "badword27";
word[28] = "badword28";
word[29] = "badword29";
word[30] = "badword30";
word[31] = "badword31";
word[32] = "badword32";
 

//INSTEAD OF WHAT YOU DID, I JUST SEARCHED FOR THE "BADWORD", IF IT IS NOT THERE, IT WILL RETURN -1 WHICH IS CHECKED FOR, IF IT RETURNS MORE THEN -1, THERE IS AN INDEX OF THE WORD AND A BOOLEAN IS SET TO TRUE, LATER, IT IS CHECKED TO MAKE SURE THE BOOLEAN IS FALSE (NO PROFANITY).
profanityhere=false;
for (var j = 1; j <= numberOfWords; j++) {
if (isProfane[j].search(word[j])!=-1) {profanityhere=true;}
}
 

   if (profanityhere) {
      alert("We DO NOT accept this type of website \'"+word[j]+"\'.");
      usersInput = message;
      j = numberOfWords + 1; }
 
   else {}
}
      return usersInput;
}
 
function makeArray(n) {
   this.length = n
   for (var i = 1; i<=n; i++) {
       this[i] = new String();
   }
   return this;
}
//-->
</SCRIPT>


the code you had before, i edited to go and search(), instead and if a word is there it will return an index for example...

var str1="'the code you had before",str2="the code you badword had before";

if i were to go and have it search for that word...

var ans1=str1.search("badword");
ans1 would = -1 because there is not index for the word "badword"

var ans2=str2.search("badword");
ans2 would = 13 because the word "badword" starts at the index 13


hope this helps

colton22

Last edited by colton22 : September 25th, 2006 at 04:25 PM. Reason: added description...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Onblur help, please


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway