{
var frm = document.forms["myform"];
if(frm.FirstName.value == 'Bob')
{
sfm_show_error_msg("Bob, you can't submit this form. Go away! ");
return false;
}
else
{
return true;
}
}
I want to check if the whole string “frm.formfeild.value” contains the word “http://” anywhere in it? I want to “not” include any “http://” in a form field
I would use indexOf;
if(frm.FirstName.value.indexOf(“Bob”) > -1) /* is Bob in there
anywhere? /
or
if(frm.FirstName.value.indexOf(“Bob”) == 0) / does the value
start with Bob? */
Regards,
Tim.
On 8 Sep 2009, at 09:36, WebWorker wrote:
Sorry, Maybe I did not make myself clear enough.
This check if the name “is” bob…
{
var frm = document.forms["myform"];
if(frm.FirstName.value == 'Bob')
{
sfm_show_error_msg("Bob, you can't submit this form. Go away!
");
return false;
}
else
{
return true;
}
}
I want to check if the whole string “frm.formfeild.value” contains
the word “http://” anywhere in it? I want to “not” include any
“http://” in a form field
Sorry, I just assumed you couldn’t get that block of code working, my
mistake.
On 8 Sep 2009, at 09:55, Tim Plumb wrote:
I would use indexOf;
if(frm.FirstName.value.indexOf(“Bob”) > -1) /* is Bob in there
anywhere? /
or
if(frm.FirstName.value.indexOf(“Bob”) == 0) / does the value
start with Bob? */
Regards,
Tim.
Yep, or match() which returns null if not found, so you can use: