Use HTML5 form validation and jQuery to send data to database -


im looking use html5 form subscriptions. email type , required used email. running jquery script when submit clicked send data page via ajax. problem jquery script still being run if html5 validation shows error. how can stop script running if error shown.

<form class="subscribe" id="email" method="get">     <input class="email" id="emailaddress" name="email" type="email" placeholder="example@email.com" required>     <input class="button" type="button" id="emailsub" value="subscribe"> </form>  $('#emailsub').on('click', function(){     var email = $('#emailaddress').val();     $.ajax({         type:"get",         url: "dosubscribe/",         data: {email: email},         success: function(result){             $('#subresult').html(result);         }     }); }) 

$(document).ready(function(){     $('#email').submit(function(){         doajax();         return false;     })     function doajax(){         var email = $('#emailaddress').val();         $.ajax({             type:"get",             url: "dosubscribe/",             data: {email: email},             success: function(result){                 $('#subresult').html(result);                 return false;             }         });     } }); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -