Welcome Guest, Not a member yet? Register   Sign In
validation withtout form..can?
#1

[eluser]tnathos[/eluser]
hi, in my app i use ajax-jquery for send the data to the db.. in the function the jquery i use a javascripts for validate the fields.. for example empty, password etc..

i am interest in use the validation what CI have.. but whit i use ajax.. i dont use <form>.. so its possible use ajax whit validation CI whitout form?

thanks.
#2

[eluser]Thorpe Obazee[/eluser]
The only difference you're going to do is change the event listener from your_form.submit() to your_button_or_whatever.click().

Code:
<script type="text/javascript">
$(document).ready(function() {
$('#registration_form_submit').click(function(){
         $.post("<?php echo site_url(current_url());?>", {
             username: $('#username').val(),
             first_name: $('#first_name').val(),
             last_name: $('#last_name').val(),
             password: $('#password').val(),
             passconf: $('#passconf').val(),
             email: $('#email').val(),
          },
          function(data){
                  alert(data);
          }
  );
  return false;
});
});
</script>
#3

[eluser]tnathos[/eluser]
thanks!




Theme © iAndrew 2016 - Forum software by © MyBB