JavaScript Archive

Dynamically change the form action using JavaScript

<a onclick=”$(‘form’).attr(‘action’, ‘’); $(‘form’).submit();” title=”submit form”> on anchor tag dynamically change the form action and submit using JavaScript </a>

javascript for phone number format

Useful link for ‘javascript for phone number format’:

Day 14: Submit form without submit button

Sometime it’s require to submit the form on server without submit button, like on dropdown change. So this can be done with the help of JavaScript.

Regular Expressions in JavaScript

With the help of Regular Expressions we can make our own patterns for validation and validate form as per our requirement. This post will describe how you

Minimum Character Validation

In JavaScript we can check the numbers of characters entered in Text Box and validate minimum or maximum numbers of characters in textbox. example: <html> <script> function validate()

Required Field Validation

One of the important use of JavaScript is Client Side Validations. We can validate the form’s data before sending to the server. example: Required Field Validation (can’t leave the

“this” Keyword

“this” refer to the object on which a method is being invoke. We can pass “this” as an argument in function, as in given examples: example

Populate Div with JavaScript

We can fill div dynamically with the help of JavaScript, using innerHTML. As the example given below. <html> <head> <script type=”text/javascript”> function fillDiv(){ var sub = document.getElementById(‘msgDiv’); var txtVal


getElementsByName() is a method in JavaScript through which we can accesses all elements with the specified name. Example : <html> <head> <script type=”text/javascript”> function getbyNameDemo(){ var sub = document.getElementsByName(‘rbtnSubjects’);


getElementById is a function in JavaScript to access the HTML elements. It’s a function of document object and can only access by using document.getElementById. Example : <html> <script> function sum() { var