Filter Out Words With Javascript
Apr 24, 2007
On my comments system, i have things like...
if ( document.news.name.value == "" )
{
alert ( "Please Enter a Name!" );
valid = false;
}
Thats if they havent enterd a name. But i need to filter our words, so i need something like...
if ( document.news.name.value (--contains "rude words here"--)
{
alert ( "You cant post rude words" );
valid = false;
}
How can i do this?
View 10 Replies
ADVERTISEMENT
Jul 20, 2005
Let's say I want to filter the contents of a target web page, and
present a simpler page on the screen.
For example, let's say a target web page is full of links, text, images,
forms, etc. and I want to present a simple page containing just the links.
The original page is not "mine", that is, I can't just edit it in
notepad and stick some javascript in it.
So, what I want to do is write some javascript on a new page that I'm
developing, that will somehow "access" or "read" the target page, scan
and find all the links, and present them to the user.
My question is, what's a straightforward way from javascript to access
the target page ?
Should I be somehow loading it into a DOM object and then "walking" the
tree ?
Or should I somehow read it's HTML as text strings and parse it looking
for anchor links ?
What functions, methods, classes, objects in javascript achieve the goal
of something accessing a remote page and "looking" at its contents.
View 11 Replies
View Related
Oct 13, 2009
i have this javascript question below,
Code:
var xHRObject = false;
if (window.XMLHttpRequest) {
[code].....
View 1 Replies
View Related
Jun 12, 2002
does anyone know of any IE filters that can colorize an image. for example, i have a regular image border around a photo (a frame) and i want to be able to show what that photo will look like with different color frame borders.
i want to be able to add a filter to the images that make up the frame so that i can colorize it in different colors through javascript.
this beats creating 200 different frame images, each representing a different color. thats a lot of management that i dont want to deal with.
the closest i came was this:
filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=0, xray=0, mirror=0, invert=0, opacity=1, rotation=0)
View 5 Replies
View Related
Feb 24, 2011
I have an array of strings, like this:
[Code]...
Now i got a function newgame() and i wanna display random word from this array in rectangles gray styled...
Here is the problem. I can make to display random words, but i dont know how i make this words with the css style together - rectangels around a char. But the words are different length so i dunno?
[Code]..
View 10 Replies
View Related
Apr 20, 2003
<script language="JavaScript1.2" type="text/javascript">
function num2words (num) {
num = num.replace(/[^0-9]/, ""); //removes all non-numeric characters.
break3 = new Array ("","Thousand","Million","Billion","Trillion","Quadrillion","Quintillion");
one2twenty = new Array ("","One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen");
tens = new Array("","","Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety");
num_split = new Array();
for ( x=Math.ceil(num.length/3); x>0; x-- ) {
if ( num.length > 3 ) {
num_split[num_split.length] = num.substring(num.length-3,num.length);
num = num.substring(0, num.length-3);
} else {
num_split[num_split.length] = num;
num = "";
}
}
num_split = num_split.reverse();
ret = "";
for ( x in num_split ) {
suff = num_split.length-x-1;
val = num_split[x];
if ( val < 20) {
val = one2twenty[val];
hun = "";
} else {
if ( val >= 100 ) {
hun = one2twenty[val.charAt(0)]+" Hundred ";
ten = val.charAt(1);
one = val.charAt(2);
} else {
hun = "";
ten = val.charAt(0);
one = val.charAt(1);
}
if ( one == 0 ) {
val = tens[ten]+one2twenty[one];
} else if ( ten >= 2 ) {
val = tens[ten]+"-"+one2twenty[one];
} else {
val = one2twenty[ten.one];
}
}
ret += hun+val+" "+break3[suff];
if ( suff != "" ) ret += ", ";
}
return ret;
}
document.write(num2words("1275h33"));
</script>
View 6 Replies
View Related
Aug 1, 2006
Is there a function that would remove character beteen two words?
eg:
suppose i had a "hello this is me how are you doing" and i pass me and you i want the string to be "hello this is me you doing"
View 3 Replies
View Related
Aug 9, 2002
This JavaScript is a "Word Filter". It is a type of form validator. When the user submits some text, the validator will check the text for words that has to be filtered.
The words that have to be filtered must be added to the array swear_words_arr. When the user types the text and hits the submit button, if the text contains any word that is present in the array swear_words_arr, the form will not be submitted.
The script can be used for validation of swear words etc.
<html>
<head>
<title>Word Filter</title>
<!--BEGIN WORD FILTER JAVASCRIPT-->
<script language="JavaScript1.2">
// Word Filter
// (c) 2002 Premshree Pillai
// http://www.qiksearch.com
// http://javascript.qik.cjb.net
var swear_words_arr=new Array("bloody","war","terror");
var swear_alert_arr=new Array;
var swear_alert_count=0;
function reset_alert_count()
{
swear_alert_count=0;
}
function validate_user_text()
{
reset_alert_count();
var compare_text=document.form1.user_text.value;
for(var i=0; i<swear_words_arr.length; i++)
{
for(var j=0; j<(compare_text.length); j++)
{
if(swear_words_arr[i]==compare_text.substring(j,(j+swear_words_arr[i].length)).toLowerCase())
{
swear_alert_arr[swear_alert_count]=compare_text.substring(j,(j+swear_words_arr[i].length));
swear_alert_count++;
}
}
}
var alert_text="";
for(var k=1; k<=swear_alert_count; k++)
{
alert_text+="
" + "(" + k + ") " + swear_alert_arr[k-1];
}
if(swear_alert_count>0)
{
alert("The form cannot be submitted.
The following illegal words were found:
_______________________________
" + alert_text + "
_______________________________");
document.form1.user_text.select();
}
else
{
document.form1.submit();
}
}
function select_area()
{
document.form1.user_text.select();
}
window.onload=reset_alert_count;
</script>
<!--BEGIN WORD FILTER JAVASCRIPT-->
</head>
<body bgcolor="#FFFFFF">
<!--BEGIN FORM-->
<table cellpadding="10" style="border:2 solid #FF9900" width="200" align="center"><tr><td>
<form name="form1" method="post" action="post.cgi">
<center><font face="Times New Roman" size="6pt" color="#606060"><b><i>Word Filter</i></b></font></center>
<table><tr><td></td></tr></table>
<textarea rows="3" cols="40" name="user_text" style="border:2 solid #808080; font-family:verdana,arial,helvetica; font-weight:normal; font-size:10pt" onclick="select_area()">Enter your text here...</textarea>
<table><tr><td></td></tr></table>
<center><input type="button" style="background:#EFEFEF; border:2 solid #808080; width:100%; cursor:pointer" value="Submit" onclick="validate_user_text();"></center>
</form>
</td></tr></table>
<!--END FORM-->
</body>
</html>
View 1 Replies
View Related
Sep 29, 2002
Filter out words from multiple fields:
<html>
<head>
<title>Word Filter</title>
<!--BEGIN WORD FILTER JAVASCRIPT-->
<script language="JavaScript">
// Word Filter 2.0
// By Premshree Pillai
// http://www.qiksearch.com
var swear_words_arr=new Array("bloody","war","terror");
var swear_alert_arr=new Array();
var swear_alert_count=0;
function reset_alert_count()
{
swear_alert_count=0;
}
function wordFilter(form,fields)
{
reset_alert_count();
var compare_text;
var fieldErrArr=new Array();
var fieldErrIndex=0;
for(var i=0; i<fields.length; i++)
{
eval('compare_text=document.' + form + '.' + fields[i] + '.value;');
for(var j=0; j<swear_words_arr.length; j++)
{
for(var k=0; k<(compare_text.length); k++)
{
if(swear_words_arr[j]==compare_text.substring(k,(k+swear_words_arr[j].length)).toLowerCase())
{
swear_alert_arr[swear_alert_count]=compare_text.substring(k,(k+swear_words_arr[j].length));
swear_alert_count++;
fieldErrArr[fieldErrIndex]=i;
fieldErrIndex++;
}
}
}
}
var alert_text="";
for(var k=1; k<=swear_alert_count; k++)
{
alert_text+="
" + "(" + k + ") " + swear_alert_arr[k-1];
eval('compare_text=document.' + form + '.' + fields[fieldErrArr[0]] + '.select();');
}
if(swear_alert_count>0)
{
alert("The form cannot be submitted.
The following illegal words were found:
_______________________________
" + alert_text + "
_______________________________");
return false;
}
else
{
return true;
}
}
</script>
<!--END WORD FILTER JAVASCRIPT-->
</head>
<body bgcolor="#FFFFFF">
<!--BEGIN FORM-->
<font face="verdana,arial,helvetica" size="-1">
<form name="form1" method="get" action="" onSubmit="return wordFilter('form1',['name','email','subject','message']);">
<table>
<tr><td>Name :</td><td><input type="text" name="name"></td></tr>
<tr><td>E-mail :</td><td><input type="text" name="email"></td></tr>
<tr><td>Subject :</td><td><input type="text" name="subject"></td></tr>
<tr><td>Message</td><td><textarea name="message" rows="5" cols="30"></textarea></td></tr>
</table>
<input type="submit" value="Submit Form">
</font>
</form>
<!--END FORM-->
</body>
</html>
View 3 Replies
View Related
Nov 21, 2005
I found this script for filtering data in HTML tables that is simple and works in all modern browsers. However, I don't know how to modify the script so that it would search for multiple separate keywords.
View 8 Replies
View Related
Apr 7, 2007
What would be the best way to test for IE only, and IE less than 7 (without conditional comments)?
I want to apply alphaImageLoader via a JS function, but I am not sure of best way to only target IE 5.5 --> 6/PC.
Any tips?
View 9 Replies
View Related
May 26, 2011
I am in position to get the no. of lines in a 'div' and the words in each line inside a div tag. Is this possible to achieve using jquery. I have googled for so many hours but could not find any results related to my requirement.
View 3 Replies
View Related
Sep 21, 2009
Is there any way to convert a number stored as a javascript variable into words? Something like...
var num=120394;
then run that var through a function and have the output be:One hundred twenty thousand three hundred ninety four
View 3 Replies
View Related
Dec 2, 2009
How to mouse over the image then the words will appear below it?
View 2 Replies
View Related
Oct 30, 2011
I'm using a script for getting yahoo weather forecast on my site. The script includes and html file and a js file that do the job. translating description words that comes from rss feed like "Clear", "Humidity", "Storm", etc... I now that in php exist something like preg_replace function, but i have no clue how to do it in js. This is the js file:
/**
* Plugin: jquery.zWeatherFeed
*
* Version: 1.0.2
[Code]....
View 1 Replies
View Related
Aug 31, 2010
how do i limit this textfield to three words?
<input type='text' size='40' name='search' style='font-size:16px; font-family:Arial;font-weight:bold;' />
i only want three words to be allowed entered.
View 1 Replies
View Related
Jun 14, 2010
I need a function like reverseChars(str_arg) � this will return a string containing the characters of the string str_arg in reverse order. For example, if reverseChars("javascript") is called, the return value will be "tpircsavaj".
View 9 Replies
View Related
Oct 29, 2004
<form action="action.htm" method="post" >
<input name="title">
<input type="submit" value=" post ">
</form>
I have the above form code. I like to make users not to enter two words, for example "FK" and "ST."
View 3 Replies
View Related
Dec 24, 2010
I have a long paragraph and I have been asked to display words in red and green in such a way that that fist word should be red, 2nd word should be green, 3rd word should be red and 4th word should be green and so on
For example: this is just a sample.
View 11 Replies
View Related
Jul 9, 2011
I have a button and a textarea. I want this button to add tags around the selected words in that textarea. For example the button is to add the <b> tag before the selected words and the </b> tag after the selected words. Just like these buttons, in the forms of creating a new thread,that are used to make the font of the selected words bold, italic, underlined or colored.
View 5 Replies
View Related
Jul 20, 2005
How can i read the light filter properties?
I have a divide with id="pic". I have assigned a light filter -
pic.style.filter='light()'
I have assigned an ambient and two cones to the filter and made an interface
to change the parameters. I now need to read the status of the filter in
order to save the states. I have tried pic.filters.item(0).ambient.color -
pic.filters.light.anbient.color and some other variations but nothing
returns a value.
View 2 Replies
View Related
Jun 14, 2009
I would like to copy/clone the html DOM from "id1" to variable "tblContent",and remove the tag "<script>" and "<a>" from variable "tblContent", then append the html DOM to "id2" but not working...any error of my code? [code]
View 1 Replies
View Related
May 11, 2010
Is there any way to filter content by multiple parameter using jQuery
Something like in this site [url]but in my case I need to filter content using 3 different parameters. Price, Size and Location.
View 5 Replies
View Related
Aug 3, 2009
if I have 3 div, how to filter the div without class abc?
<div></div>
<div class="abc"></div>
<div></div>
View 5 Replies
View Related
Mar 12, 2011
I would to achieve the same result of the below function without using callbacks .
The function is:
$("#user-options-menu").find('a').each(function() {
// now I want to filter any <a> tag with <li> parent
if (!($(this).parent().is('li'))) {
$(this).button();
}});
I've tried with$("#user-options-menu").find('a:not(li:parent)') but without result.
View 2 Replies
View Related
Sep 7, 2010
I wanted to put data in dropdown..but capacity of data is arround 6000 to 8000,is their any method like multi-filter drop down?how to do it?
View 2 Replies
View Related