Send POST data using XMLHttpRequest

The code below demonstrates on how to do this. var http = new XMLHttpRequest(); var url=”get_data.php”; var params=”orem=ipsum&name=binny”; http.open(‘POST’, url, true); //Send the proper header information along with the request http.setRequestHeader(‘Content-type’, ‘application/x-www-form-urlencoded’); http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { alert(http.responseText); } } http.send(params); In … Read more

Chrome ignores autocomplete=”off”

Prevent autocomplete of username (or email) and password: <input type=”email” name=”email”><!– Can be type=”text” –> <input type=”password” name=”password” autocomplete=”new-password”> Prevent autocomplete a field (might not work): <input type=”text” name=”field” autocomplete=”nope”> Explanation: autocomplete still works on an <input>despite having autocomplete=”off”, but you can change off to a random string, like nope. Others “solutions” for disabling the … Read more

Get checkbox value in jQuery

To get the value of the Value attribute you can do something like this: $(“input[type=”checkbox”]”).val(); Or if you have set a class or id for it, you can: $(‘#check_id’).val(); $(‘.check_class’).val(); However this will return the same value whether it is checked or not, this can be confusing as it is different to the submitted form … Read more

What characters are allowed in an email address?

See RFC 5322: Internet Message Format and, to a lesser extent, RFC 5321: Simple Mail Transfer Protocol. RFC 822 also covers email addresses, but it deals mostly with its structure: addr-spec = local-part “@” domain ; global address local-part = word *(“.” word) ; uninterpreted ; case-preserved domain = sub-domain *(“.” sub-domain) sub-domain = domain-ref … Read more

Prevent users from submitting a form by hitting Enter

You can use a method such as $(document).ready(function() { $(window).keydown(function(event){ if(event.keyCode == 13) { event.preventDefault(); return false; } }); }); In reading the comments on the original post, to make it more usable and allow people to press Enter if they have completed all the fields: function validationFunction() { $(‘input’).each(function() { … } if(good) { … Read more

jQuery AJAX submit form

This is a simple reference: // this is the id of the form $(“#idForm”).submit(function(e) { e.preventDefault(); // avoid to execute the actual submit of the form. var form = $(this); var actionUrl = form.attr(‘action’); $.ajax({ type: “POST”, url: actionUrl, data: form.serialize(), // serializes the form’s elements. success: function(data) { alert(data); // show response from the … Read more

How do you disable browser autocomplete on web form field / input tags?

Firefox 30 ignores autocomplete=”off” for passwords, opting to prompt the user instead whether the password should be stored on the client. Note the following commentary from May 5, 2014: The password manager always prompts if it wants to save a password. Passwords are not saved without permission from the user. We are the third browser … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)