/    Sign up×
Community /Pin to ProfileBookmark

Odd Question…

Good evening guys. I don’t know if this is possible, if it’s not is there anything else you can recommend?

I have a site with several ‘application’ forms. I’ve already filtered some abuse by making fields required and checking email addresses are formed correctly, and it only contains valid characters etc.

I’ve seen elsewhere ‘Human Input’ where a random image is shown containing a word, which must be inputted into a field. Is there a way I can achive this? My host doesn’t support PHP… or is theer any other ideas to try and stop false applications?

Lastly, I have a password form… which looks something like:

else if (form.userPASS.value ==””) {
alert(“Please include your desired username password.”);
form.userPASS.select(); }

Is there way to having ‘minimum’ characters? I’ve already got maxlength etc…

Thanks for any infos you can give me.

:rolleyes:

to post a comment
JavaScript

16 Comments(s)

Copy linkTweet thisAlerts:
@DanUKauthorApr 16.2003 — I was just thinking, this could be anything, not even an image, perhaps a 'number' that comes up somewhere or something : hehe
Copy linkTweet thisAlerts:
@DrDaMourApr 16.2003 — since you aren't using php or any othe rserver side code, what i would do for hte human test is generate a random number

var x = Math.round((Math.random() * 100) + 1));

then print it out using document.write or innerHTML or something, then when teh form is submitted check the users input against the variable x. It's a cheap way to do it, but if your code really is only on client side, then this shoudl be enough for you
Copy linkTweet thisAlerts:
@DrDaMourApr 16.2003 — yeah but my thought was that if this form is really going to be server side, then there definately isn't a big likelyhood that it's so useful that someone would bother to write that program. But of course why woudl you need the verify anyways...what came first the chicken or the egg?
Copy linkTweet thisAlerts:
@DanUKauthorApr 17.2003 — hi again.

how should this one ( var x = Math.round((Math.random() * 100) + 1)); ) be coded? Idont really understand...sorry and thanks for any hlep.
Copy linkTweet thisAlerts:
@DrDaMourApr 17.2003 — x is now a randomly generate number, so you have to output it to the screen whereve you want.....document.write(x) would be one solution.
Copy linkTweet thisAlerts:
@DanUKauthorApr 17.2003 — i'll try ... thanks *clueless look*
Copy linkTweet thisAlerts:
@DrDaMourApr 17.2003 — i'm sorry dude, stop doing that clueless thing, it makes noone happy and start learning [URL=http://developer.netscape.com/docs/manuals/js/client/jsref/index.html]this[/URL] then we can all be happy. What you're asking to do takes some decent conceptual grasp of JS.
Copy linkTweet thisAlerts:
@DanUKauthorApr 17.2003 — I'm sorry if i annoyed anyone, that wasn't my intention. Can i please show something that i wrote earlier:

Thanks for the help. Here's my £0.02 worth ... I know it must be frustrating for you guys having to answer all types of queries etc, and to you, I understand, it must seem like we just take what you say and don't try at all. Some people like me, really don't find things like this easy. I personally spent a lot of time learning HTML, or trying to, javascript I could never really understand or try to get working. That's why people liek you, and places like this are brililiant. It might not show that people are actually thankful for your help, but personally I am. anyway thanks again __________________ Kind regards, Daniel. [/QUOTE]

Once again...sorry if I annoyed you in any way.
Copy linkTweet thisAlerts:
@DanUKauthorApr 18.2003 — I still can't get this going.

I've tried putting

<script>

var x = Math.round((Math.random() * 100) + 1));

</script> in the HEAD.

and in BODY a print...
Copy linkTweet thisAlerts:
@DanUKauthorApr 19.2003 — ok that works, the original one i put did but not in the right place, but how can i make it check the number specified matches what the user enters into a box before allow to submit? Or is there's osmething i can read to show me?

thanks
Copy linkTweet thisAlerts:
@DanUKauthorApr 19.2003 — thanks so much dave !!!

if i was going to incorporate this into my following code, would i do it like this? The field is named 'hin'

var nbr = Number(document.fm.hin.value);

if (nbr != rnd) {

errors += "You must enter the number shown.;r";

fm.hin.select();

}

script :

function simpleCheck(fm) {

var errors = "";

if (!/^[a-z0-9]+$/i.test(fm.newuser.value)) {

errors += "Please include your desired use;r";

fm.newuser.select();

}

if (fm.userPASS.value =="") {

errors += "Please include your desired user password;r";

fm.userPASS.select();

}

if (fm.userRPTPASS.value =="") {

errors += "Please repeat your desired user password;r";

fm.userRPTPASS.select();

}

if (fm.userPASS.value != fm.userRPTPASS.value) {

errors += "Your passwords did not match, please try again;r";

fm.userPASS.select();

}

if (!/^w+@w+.[a-z]{2,3}(.[a-z]{2})?$/i.test(fm.userEMAIL.value)) {

errors += "Please include your e-mail address. Should be in '[email protected]' format;r";

fm.userEMAIL.select();

}

if (fm.policyON.checked==false) {

errors += "You forgot to tick the box stating you agree to our terms;r";

fm.policyON.select();

}

if (errors != "") {

errors = errors.substr(0,errors.length-2);

alert("The following fields were misformed, please retry:r" + errors + ".");

return false;

}

return true;

}
Copy linkTweet thisAlerts:
@DanUKauthorApr 19.2003 — thanks alot dave. works PERFECT!
Copy linkTweet thisAlerts:
@DanUKauthorApr 19.2003 — Hi again.

Using the code I pasted above (the Javascript for form validation) is there anything there that could cause 'odd' look with Konqueror/Mozilla browser? It is fine in my Internet Explorer but under Konqueror/Mozilla it looks really long, as if a 'new line' hasn't begun, it just carries on and looks wrong.

Any info you can give will be gratefully appreciated. Many thanks.
Copy linkTweet thisAlerts:
@DanUKauthorApr 19.2003 — brilliant thanks !
Copy linkTweet thisAlerts:
@DanUKauthorApr 20.2003 — hi again.

If i wanted the number generation to be within 1000, do i just change

rnd = Math.round((Math.random() * 100) + 1);

to

rnd = Math.round((Math.random() * 1000) + 1);

and that would give a random number between 0 and 1000?

Thanks !
Copy linkTweet thisAlerts:
@DrDaMourApr 20.2003 — it never hurts to try something out before you get verfication of it's correctlness in javascript. It's not like it's the A-Bomb
×

Success!

Help @DanUK spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...