[eluser]Unknown[/eluser]
Hello everyone i'm currently working on a validation with Jquery. I am confused on the structure of my validation on the client end (jquery)
Issue:
When i click submit with all fields not being touched..i get my validation errors but once i change say (country in my validation) then click submit it points straight to the else statement even though i didnt correct the other fields. So baiscally its by passing the other IF statements and going straight to the else. I dont know if my structure is correct...but at the moment i have some backend validation and i wanted to do a check box, select (drop down) validation in the front end per my example below.
Any idea on how i can fix this issue?
JS
Code:
jQuery(document).ready(function() {
$('#regform').submit(function(){
$.ajax({
url: $(this).attr('action'),
type: 'POST',
data: $(this).serialize(),
dataType: 'json',
success: function(respond) {
if (respond.result == 'false') {
$('#feedback').html(respond.errors);
}
if($('#agree:checked').val()==undefined) {
$('#return').html('Please agree to the terms and conditions to register');
}
if($('#country').val()=="") {
$('#returncountry').html('Please select a country');
}
else {
[removed] = 'http://localhost/code/index.php/user/nextpg';
//$('please agree to the terms and conditions').appendTo('#feedback')
}
}
});
return false;
});
});