1
Do not allow the filling of numbers in sequence with spaces or without spaces, to avoid adding phone numbers.
Avoid sequences such as:
99999999999
99 9 9999 9999
and any other number having more than 7 numbers sequentially.
The code makes a split and checks each word, if it has more than 7 characters, but, logically, it is functional only with numbers in sequence without space.
$('input:text, textarea').keyup(function(){
var num = $(this).val();
var texto = num.split(" ");
var a1 = num.split(" ");
for (i=0;i<a1.length;i++)
{
var total_letras = a1[i].length;
if($.isNumeric(a1[i])){
if( $(this).attr("id") !== 'input_cep' )//se id for cep, permitirá a digitação
{
if(total_letras > 7)
{
$(this).val( num.substring(0, num.length - 2) );
$(this).addClass("input_bloqueado");
}
else
{
$(this).removeClass("input_bloqueado");
}
}
}
}
});
What value should return ? Example: 11999933333333 2 3333 1 77777 777 1
– Maury Developer
@Maurydeveloper the idea is to block the typing of any numerical sequence larger than 7 digits, with or without spaces
– sNniffer
Do you want the answer with Jquery or pure Javascript? Note: I hate jQuery,.
– Maury Developer
without preference, can be javascript
– sNniffer
textarea takes more than one 'field'? attribute
maxlength
doesn’t help him?– vik
var reg = /([0-9]{7})/g; str.replace(" ","").replace(reg,"");
Removes sequence of 7 in a row– Maury Developer
https://answall.com/questions/295543/howto Detect One Determinatedsequence OneJavascript Also similar
– Maury Developer
@Maurydeveloper saved in jsfiddle or as a response
– sNniffer
Worked that code?
– Maury Developer
https://jsfiddle.net/sNniffer/3ksdguw7/1/ - Text interference appears to be present or is not correctly implemented
– sNniffer
True. I’ll try another way.
– Maury Developer