Javascript

Validate textbox using jquery

Validating text box using jquery

Use the following code to validate all text boxes in jquery if($('input:text').is(":empty")){ alert("Field is empty"); }   ..

Find ajax error in jquery

Get the ajax error code

How to find ajax response error message or error code in jquery. At time you might want to find what is the error code return by ajax, in such situation you can use the below code $.ajax({ type: 'POST', url: 'Your url here', data: "email="+email, success: function(data) { $('#res').html(data); }, error: function(xhr, status, error) { alert("\nError: "  ..

Script to remove special chars except space

Accept space and not other special chars

Remove all non alphabets or special characters except space from a string using javascript. Some times we might have a need to accept only space in a text box, while we a name or college details in to the text box. In such conditions you can use below script as  ..

Json array function

Javascript json array

function array1dToJson(a, p) { var i, s = '['; for (i = 0; i < a.length; ++i) { if (typeof a[i] == 'string') { s += '"' + a[i] + '"'; } else { // assume number type s += a[i]; } if (i < a.length - 1) { s += ','; } } s += ']'; if (p) { return '{"' + p +  ..

Json array with javascript

Json script to add states

How to create a array in json? By using the simple javascript function as below you can create a simple array in json var head = { "data" : [ { "name" : "Math", "place" : "Alaska" },   ..

Encode string in javascript

How to encode a string using javascript

Encode string in Javascript: Use escape() to encode a string in javascript. This function encodes special characters, with the exception of: * @ - _ + . / ... <script type="text/javascript"> document.write(escape("w3calculator.com - Web Master Resource!!!!!")); </script> Output: w3calculator.com%20-%20Web%20Master%20Resource%21%21%21%21%21   ..

Advantages and disadvantages of ajax

Importance of AJAX

Advantages: 1. XMLHttpRequest - It is used for making requests to the non-Ajax pages. It supports all kind of HTTP request type. 2. IFrame - It can make requests using both POST and GET methods. It supports every modern browsers. It supports asynchronous file uploads 3. Cookies - In spite of implementation  ..

How to get domain name from url

Document.domain to get url

To get a domain name from url, use "document.domain". document.domain Output: info.w3calculator.com Just use "document.domain" to get domain name from url using javascript.   ..

How to sort an array in numerical order

Function sorting an array

To sort an array in numerical order, use the function array.sort(). var myarray=[25, 101, 10, 33] myarray.sort() //Array now becomes [10, 101, 25, 33] The above code will see only the first number. So it returns the result as 10, 101, 25, 33 To Sort an array in numerical order or in ascending order var  ..

Edit webpage from browser

Edit code with firefox browser

This code lets you edit any page/website in real-time . With Firefox, you can even edit and save the modified pages to your computer. javascript:document.body.contentEditable='true'; document.designMode='on'; void 0   ..

How to find a domain in vulnerable to attack or not

Spoffing website

This is a simple javascript code find whether your domain or website is vulnerable to attack or not. This JavaScript code's result should match with the server name, if they do not match then the server might be spoof. javascript:alert("The actual URL is:\t\t" + location.protocol + "//" + location.hostname + "/"  ..

Buzz internet explorer

Shake the ie browser

Javascript Fun code to buzz Internet Explorer browser Just copy the below code and paste in the address bar of your IE browser and press enter. It will buzz or shake the IE browser untill you interrupt or click anywhere on the browser Javascript Fun code to buzz IE javascript:function flood(n) {if (self.moveBy)  ..

How to find datatype of variable

Typeof() function

How to find type of variable name? Javascript has a special function called typeof which prints the datatype of a variable. When you do code some time the error may be triggered because improper useage of datatype. In such scenario you can use the typeof function to the the data  ..

Previous 1 2 3

Tech Bluff