Special Characters

Hello

Anyone know what’s wrong with my code?

function verify(){
	for  (var i=1; i<5 ;i++){	
		var valor= "title"+i;
		alert(valor);
		var el=document.getElementById(valor);
		var re=/^[a-zA-Z0-9 ]+$/;
		if(!re.test(el.value)) 
		{
			alert("Remove special characters!");
			document.getElementById(valor).value="";
		}
}
}

Thanks!

Have you tried jshint or jslint?
What are you expecting from your codes?

I’m trying another option:

I want verify the input not empty with this (with array):

function verificarMovies(){
	var contador = 0;
for (var i=1; i<=30;i++){	
		if(document.getElementById("tituloep"+i).value!=""){
			var count = new Array();
			count [i] = "tituloep"+i;
			contador++;
		}
}
}

and after, verify if input with text respect this regular expression: /[1]+$/

Thanks!


  1. a-zA-Z0-9 ↩︎

Solved! Thanks.