-1
I have a form, and I’d like to remove the random characters. Type:
aaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccc
20323092093023029302
weweiowoeiow
o392039209320939
Description: Not just these, I would like to make the form a little secure. Prevent the user from creating things like this. The script below makes an Random "randomness" wanted to use this to prevent this event....
function generateRandomNumber(){
"use strict";
// se o browser tiver suporte à getRandomValues()
if (Uint32Array && window.crypto && window.crypto.getRandomValues) {
var numbers = new Uint32Array(1);
window.crypto.getRandomValues(numbers);
return numbers[0] * Math.pow(2,-32);
// caso não tenha, é utilizado Math.random
} else {
return Math.random();
}
}
function shuffle(string) {
"use strict";
var parts = string.split('');
for (var i = parts.length; i > 0;) {
var random = parseInt(generateRandomNumber() * i); // aqui é chamada a função que gera o número aleatório
var temp = parts[--i];
parts[i] = parts[random];
parts[random] = temp;
}
return parts.join('');
}
It was not clear what he wanted to do and much less because the characters cited were considered "random". Could you elaborate a [mcve] for your problem?
– Woss
Could define what random characters are?
– RXSD
Would that be "aaaaaaaaaaaaaaaaaaaaaaaaaaa" "sdskjksdkjsjdk" "dksjkjjk23jk23kj" Rs...
– user142085
I did not understand. You want to prevent "random numbers" in your form and has a function that "generates" such numbers? What is the function for?
– Sam
Rs.... is an example... I want to prevent "random numbers"... And I used this example, wanted to understand how it works... to prevent this.
– user142085
If you need to validate user-provided data, take a look at regular expressions and mask application, just to get started. There is vast material on this content on the internet (handle user data - user input).
– marconato
okay ;D you are beast and whenever I can include all the names in my 'programs'
– user142085
There is no way to predict what a user can type to circumvent an input, even when there are no phone masks I fill "Semtelefone", "Sememail".
– Vinicius De Jesus
You’re right ;D face
– user142085
People, with the answer! Can I create a regular expression with certain patterns and block or prevent it from being done in the input? The example below, the friend mentioned that it is possible to create a dictionary and prevent these words! Now, I think you could use regular expressions to make a pattern and so prevent or block via input? Example, the pattern 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' .... the expression could be 'a' (sequence). If 'a-z has a sequence without space' = lock, prevent.
– user142085
If a-z has randomness... Example, 'askdjskdksjdkjskdjsdkjweowieoweiwoieoweowie' = block, prevent.
– user142085