/* dumper.tt function */ function toggleview_dumper (id1,id2) { var obj1 = document.getElementById(id1); var obj2 = document.getElementById(id2); (obj1.className=="itemshown") ? obj1.className="itemhidden" : obj1.className="itemshown"; (obj1.className=="itemshown") ? obj2.innerHTML="[...]" : obj2.innerHTML="[...]"; } /* for bootsnipp login */ function showPassword() { var key_attr = $('#key').attr('type'); if(key_attr != 'text') { $('.checkbox').addClass('show'); $('#key').attr('type', 'text'); } else { $('.checkbox').removeClass('show'); $('#key').attr('type', 'password'); } } // magic.js $(document).ready(function() { // process the form $('#patient-details').submit(function(event) { $('.form-group').removeClass('has-error'); // remove the error class $('.help-block').remove(); // remove the error text // get the form data // there are many ways to get this data using jQuery (you can use the class or id also) var formData = { 'email' : $('input[name=email]').val(), 'password' : $('input[name=password]').val() }; // process the form $.ajax({ type : 'POST', // define the type of HTTP verb we want to use (POST for our form) url : '/ajax_amend_details', // the url where we want to POST data : formData, // our data object dataType : 'json', // what type of data do we expect back from the server encode : true }) // using the done promise callback .done(function(data) { // log data to the console so we can see console.log(data); // here we will handle errors and validation messages if ( ! data.success) { // handle errors for email field --------------- if (data.errors.email) { // add the error class to show red input: $('#email-group').addClass('has-error'); // add the actual error message under our input: $('#email-group').append('