For Enquiries: CALL +91-9774064470

Form Validation: Checking if form fields are empty!!

Form validation is an important part in the development of a webpage that contains forms. Among the methods and techniques used for form validation, checking if form fields are empty plays an important role as it enables not only the users to identify which fields are compulsory but make the load on the servers lighter as the process validating the form is being done on the client side instead of utilizing the server resources. An example to check if form fields are empty is given below: function isEmpty(formname, fieldname,fieldID) { a=document.forms[formname][fieldname].value; if (a==null || a=="") { document.getElementById(fieldID).innerHTML=fieldname+" Field Empty"; return false; } } The above example takes…

Continue Reading

How to destroy a div dynamically!!

An element can be deleted or removed dynamically by using the removechild attribute. The following function demonstrate the use of the removechild attribute to destroy a div dynamically : function destroydiv(parentDiv, childDiv){ if (childDiv == parentDiv) { alert("The parent div cannot be removed."); } else if (document.getElementById(childDiv)) { var child = document.getElementById(childDiv); var parent = document.getElementById(parentDiv); parent.removeChild(child); } else { alert("Child div has already been removed or does not exist."); return false; } } In the above example childDIV is the DIV id of the DIV element that we want to destroy dynamically. parentdiv is the DIV id of the parent of the child DIV.

Continue Reading

HOW TO DYNAMICALLY CREATE A DIV ELEMENT

Dynamic DIV element can be created using the AJAX createelement function. Attributes of the element can also be assigned using the setattribute tag. An example is shown below: function creatediv(id, html, width, height, right, bottom) {    var newdiv = document.createElement('div');    newdiv.setAttribute('id', id);    newdiv.className ="dynamicDiv";    if (width) {        newdiv.style.width = width;    }        if (height) {        newdiv.style.height = height;    }        if ((right || bottom) || (right && bottom)) {        newdiv.style.position = "absolute";                if (right) {            newdiv.style.right = right;        }                if (bottom) {            newdiv.style.bottom = bottom;       …

Continue Reading