最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Javascript script to find gibberish words in form inputs - Stack Overflow

programmeradmin0浏览0评论

I need a script or regex (which I will be using with Javascript / jQuery to check form input on a website) to check if someone has entered words which are mostly gibberish.

Normal words or sentences should pass the test:

This is a normal sentence (pass)

Peterborough (pass)

Words like this should fail the test:

bfygrydyyisg (fail)

hjrrjmsjsinz (fail)

yqymuqawsioy (fail)

I'd thought of using a check of around 6 consonants or vowels in a row, but the last example above would still pass and I know some english words like 'rhythms' would fail (although that is very unlikely to be needed).

Any ideas? Thanks!

I need a script or regex (which I will be using with Javascript / jQuery to check form input on a website) to check if someone has entered words which are mostly gibberish.

Normal words or sentences should pass the test:

This is a normal sentence (pass)

Peterborough (pass)

Words like this should fail the test:

bfygrydyyisg (fail)

hjrrjmsjsinz (fail)

yqymuqawsioy (fail)

I'd thought of using a check of around 6 consonants or vowels in a row, but the last example above would still pass and I know some english words like 'rhythms' would fail (although that is very unlikely to be needed).

Any ideas? Thanks!

Share Improve this question edited Apr 19, 2012 at 10:26 Shaun asked Apr 18, 2012 at 14:02 ShaunShaun 6426 silver badges19 bronze badges 7
  • 6 I guess the word "rhythms" is also valid gibberish then? – Mark Byers Commented Apr 18, 2012 at 14:03
  • Or indeed, several of the words on this list of acceptable scrabble words: tnellen./ted/scrabble/scrabble_words_others.html – Paddy Commented Apr 18, 2012 at 14:21
  • Wow. I'm in a bit of a shock here. Does the english language actually consider 'y' a consonant? (I'm swedish by the way, and we don't) – Per Salbark Commented Apr 18, 2012 at 14:26
  • 2 Unindented code is gibberish, too... – ThiefMaster Commented Apr 18, 2012 at 15:12
  • @PerSalbark: Yes it is considered a consonant in English. – Dale Commented Apr 18, 2012 at 17:25
 |  Show 2 more ments

3 Answers 3

Reset to default 3

I run into this same problem just recently. Basically we needed to find if the form fields contained gibberish answers. We wanted to detect this fast (so as to not slow down form filling) and nudge the user to provide proper answers.

There are some newish front-end and backend libraries doing this detection.

  1. https://www.npmjs./package/gibberish-detector fairly self describing
  2. Aptly named https://www.npmjs./package/asdfjkl
  3. In Python there's also: https://github./rrenaud/Gibberish-Detector

Hope this helps others.

Maybe you could use a spellchecker API like http://www.javascriptspellcheck./ or you could refer to John Resig's http://ejohn/blog/revised-javascript-dictionary-search/

May be this disscussion might give you some direction: Help on JS gibberish detection

发布评论

评论列表(0)

  1. 暂无评论