gillweb
04-26-2006, 01:24 PM
I'm look to take the value of a textbox in a form, and see if certain keywords or words are in the value. it'sfor an intranet and it is to look to see if the value of the textbox contains a certain name. If it does it alerts and doesn't submit the form. If it doens't then it goes through normally. I have this simple yet messy code so far but it's not working:
function FastPay( theform )
{
var nochecks = new Array()
nochecks[0] = "MY NAME"
nochecks[1] = "YOUR NAME"
nochecks[2] = "HIS NAME"
var bMissingFields = false;
var strFields = "";
if( theform.name.value == '' ){
bMissingFields = true;
strFields += " Text Field Is empty!\n";
}
else if ( theform.name.value == nochecks )
{
bMissingFields = true;
strFields += "Your field contains text in the array!\n" + theform.name.value;
}
if( bMissingFields ) {
alert( "You must provide the following field(s) before continuing:\n" + strFields );
return false;
}
return true;
}
So I need it to seach through the "nochecks" array and if the value of the textbox is "MY NAME" then it would alert and not submit the form. I assume i'm not calling the fuinctions correctly here: theform.name.value == nochecks
help please :-)
function FastPay( theform )
{
var nochecks = new Array()
nochecks[0] = "MY NAME"
nochecks[1] = "YOUR NAME"
nochecks[2] = "HIS NAME"
var bMissingFields = false;
var strFields = "";
if( theform.name.value == '' ){
bMissingFields = true;
strFields += " Text Field Is empty!\n";
}
else if ( theform.name.value == nochecks )
{
bMissingFields = true;
strFields += "Your field contains text in the array!\n" + theform.name.value;
}
if( bMissingFields ) {
alert( "You must provide the following field(s) before continuing:\n" + strFields );
return false;
}
return true;
}
So I need it to seach through the "nochecks" array and if the value of the textbox is "MY NAME" then it would alert and not submit the form. I assume i'm not calling the fuinctions correctly here: theform.name.value == nochecks
help please :-)