Click to See Complete Forum and Search --> : JavaScript to disable "Submit" ?


bobafifi
03-23-2003, 03:06 AM
I need a JavaScript that will disable the "Submit" button when the Title field of the form ( http://www.usedflutes.com/addpage.html ) contains the phrase "START EARNING NOW"
Anybody have something that can do that?

Many thanks,

-Bob

bobafifi
03-23-2003, 11:52 AM
Hi Dave (again!),
I'm not sure I understand your question...
Why would I want to disable the Submit button as the default??
Maybe my question wasn't clear...
I'm just trying to deal with spammers out of India, Pakistan and Nepal that are working for some online typing scheme and use the phrase "START EARNING NOW" in the Title field.
Would love to have a JavaScript that could handle bogus phrases as they show up and would simply disable the submit button if it recognized a match.
Don't know if that is any clearer or not :-|


Thanks once again Dave for the URL fix! :-)

-Bob

Nedals
03-23-2003, 12:14 PM
If you use the re-coding I sent you, then simply add this to the 'validate()' function.

var title = document.myForm.realname.value;
and...
else if (/START\sEARNING\sNOW/i.test(title)) { alert("invalid title"); return false; }

Additionally, you can include ANY bogus phrase by simply repeating that second line with the new phrase. The '\s' is there for the 'space' char and the 'i' is included to make the phrase case insensitive.

bobafifi
03-23-2003, 12:40 PM
Hi Dave,
Returning false is fine with me (don't mind a spammer looking at a frozen screen at all!). Guess what I'm looking for then is something along the lines of:

if Title = "START EARNING NOW"
return false

As you're probably all too aware, I'm not a computer programmer so I have no idea how the above translates in JavaScript, but I think that's what I'm after...

Thanks again,

-Bob

bobafifi
03-23-2003, 02:06 PM
COOL!!
Thanks again Dave :-)

-Bob

bobafifi
04-27-2003, 08:30 PM
Hi Dave,

Is there a way that I can have both of these scripts working in the form http://www.usedflutes.com/addpage.html ? I've tried various ways of combining them but no go... :-(

onSubmit="
var fld = this.elements['url'];
if (fld.value.substr(0,7).toLowerCase() != 'http://') {
alert('URL not valid. Must start with http://');
return false;
}
return validatePwd();">

=====

with this script:


onsubmit="
if (this.realname.value=='START EARNING NOW') {
return false;
}
return true;">

=====

Also, the spammers I've been dealing with have fallen into a pattern of late. Namely, they're using my site as a referral for URL links for ad-placer.com. Is there a way to modify the above script so that it will recognize the phrase "ad-placer" if it's contained in the URL field or the Description field?

Once again, many thanks in advance Dave,

-Bob

bobafifi
04-27-2003, 11:40 PM
That works!!
Thanks so much Dave :-)

-Bob

bobafifi
05-02-2003, 01:41 PM
Hi Dave,
Occasionally I get people who post ads with an abundance of "!!!!!" , "*****" and "....." in their descriptions. I end up trimming the excess characters manually but would love to have a JavaScript that could that. Am wondering if some of the code you've provided here can be easily modified to do that?

Once again, many thanks in advance Dave,

-Bob

bobafifi
05-03-2003, 12:11 PM
Thanks Dave!
The script looks like this right now:

onSubmit="
if (this.realname.value=='Welcome to PillValue') {
return false;
}
if (this.realname.value=='Best Business Opportunity') {
return false;
}
if (this.url.value.indexOf('ad-placer')!=(-1)) {
return false;
}
if (this.url.value.indexOf('typists')!=(-1)) {
return false;
}
if (this.url.value.indexOf('hghformula')!=(-1)) {
return false;
}
if (this.url.value.indexOf('cgi.ebay.com')!=(-1)) {
return false;
}
var fld = this.elements['url'];
if (fld.value.substr(0,7).toLowerCase() != 'http://') {
alert('URL not valid. Must start with http://');
return false;
}
return validatePwd();">

=====

Not sure how to incorporate your latest JavaScript into this, or does it need to go elsehwere?

Thanks again Dave,

-Bob

bobafifi
05-03-2003, 06:22 PM
Your programming skills astound me!
Thanks so much Dave :-)

-Bob