function trim(s) { while (s.substring(0,1) == ' ') { s = s.substring(1,s.length); } while (s.substring(s.length-1,s.length) == ' ') { s = s.substring(0,s.length-1); } return s; } function isInteger(s){ var i; for (i = 0; i < s.length; i++){ // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } function verify(s, r){ if(r != '' && !isInteger(r)){ alert('Calificativul trebuie sa fie un numar'); return false; } e = trim(s); if((e.length < 2)){ alert('Sirul de cautare trebuie sa fie de minim 2 caractere.'); return false; } else return search(e); } function search(e){ var tmp = e.replace(/[ ]+/g, '-'); document['cautare'].action = '/comunitati/cautare/'+(tmp != '' ? tmp : "rezultate-cautare-utilizator")+'.html'; }