Hi guys,
A quick problem that I'm facing with a return method.
I've created a page for a friend with a questionnaire and i am validating all the radio buttons, this works nicely.
When i want to verify the input fields of text type, it alerts me but the return false; it's not kicking in.... don't know why.
<script type='text/javascript'>
window.onload = function() {
document.getElementById("trimite").onclick = function(e) {
var checked = $("#container :radio:checked");
var groups = [];
$("#container :radio").each(function() {
if (groups.indexOf(this.name) < 0) {
groups.push(this.name);
}
});
if (groups.length == checked.length) {
alert('Multumim ca ati raspuns la acest chestionar!');
// here comes the problem, this return false it's not working
$('#chestionar input[type=text]').each(function(n,element){
if ($(element).val()=='') {
alert('Trebuie sa complectati campul '+element.id);
return false;
}
});
}
else {
var total = groups.length - checked.length;
alert('Nu ati raspuns la ' + total + ' intrebari!');
return false;
}
};
};
</script>