just use the .match method:
Code:
var myurl = document.addurl.url.value;
if (myurl == "") {
alert("Please specify a url")
document.addurl.url.focus();
return false;
}
if(myurl.match('casino'))
{
alert('That is an invalid URL')
return false;
}
And if you want to check for multiple words then just put them inside of an array:
Code:
<script type="text/javascript">
function changeThem()
{
var mywords = new Array('casino','cards','poker');
var myurl = document.getElementById('ads').value.toLowerCase();
var i, word;
if (myurl == '')
{
alert("Please specify a url")
document.addurl.url.focus();
return false;
}
for(i=0;i<mywords.length;i++)
{
if(myurl.match(mywords[i]))
{
alert('That is an invalid URL. The word ' + mywords[i] + ' cannot be used in the URL.');
return false;
}}}
just add whatever words you want to the array. In the script I changed every input to lowercase so that you don't need multiple inclusions for one word.
Bookmarks