Posts

Showing posts with the label Javascript

How to check Object is empty or not in Jquery/JavaScript ?

you can check your JavaScript OR jQuery object is empty or not, because we need to check many place our jQuery object is empty, null or undefined etc., So usually, we can check using $.isEmptyObject() as i explained as under. how to check empty object in javascript, how to check empty object in jquery, jQuery.isEmptyObject() example, jquery check object is null, jquery check object is empty, jquery check object is empty or not, how to check json object is empty or not in jquery, check if json object is empty jquery if($.isEmptyObject(your_object)){    alert("This Object is empty!"); }else{   alert("This Object is not empty!"); } you can also check other way to your object is empty or not i also describe under. if (your_object && your_object instanceof Array && !your_object.length) {    console.log('This Object is empty!'); } else {    console.log('This Object is not empty!'); }

How to set maxlength for textarea in javascript ?

Today, I was planning to post something like regarding javascript. I was thinking what post should I add and I plan to make maxlength validation with display remaining character count using javascript. So you can simply make character limit with remaining counter in javascript. Here, I am going to make a very simple example to do this, you don't require to import jquery. You have to just write following javascript code. So I used the onkeyup and the onkeydown event of code javascript. It would be easy to use using onkeydown and onkeyup event and make it character count validation in HTML. So let's just see below example and copy that code. You will get a fresh example. <!DOCTYPE html> <html> <head> <title> How to set maxlength for textarea in javascript? </title> </head> <body> <div class = "container" > <form> <textarea name = "message" placeholder = "Wri