JavaScript Coder

reference

JavaScript Form Validation : quick and easy!

Using client side JavaScript is an efficient way to validate the user input in web forms. When there are many fields in the form, the JavaScript validation becomes too complex. The JavaScript class presented here makes the form validations many times easier. Contents Download the JavaScript form validation script Using the form validation script Adding a custom validation Table of Validation Descriptors Showing the form validation errors next to the element

Continue Reading →

JavaScript Form Validation Script: More features

This is in continuation of the JavaScript Form Validation script in this page. In this page, we will see some of the advanced features of the script. Showing all the form validation errors together in a message box If you want to show all the error messages together, then just call the EnableMsgsTogether() function as shown below. frmvalidator.EnableMsgsTogether(); See the form validation demo Showing the form validation errors on the page itself You can display the validation errors on the page itself.

Continue Reading →

Simfatic Forms Validation: save your time coding

This is in continuation of the JavaScript form validation script explained here. Simfatic Forms is a complete web form development software. You can create forms add form validations, select your options for server side processing, generate the script and install the form on the web server. No coding required. This page takes you through some of the form validation features of Simfatic Forms. Add validations to your existing forms You can choose to create a new fresh form or read the form from an existing web page.

Continue Reading →

How to Submit a Form Using JavaScript

Generally, a form is submitted when the user presses a submit button. However, sometimes, you may need to submit the form programmatically using JavaScript. JavaScript provides the form object that contains the submit() method. Use the ‘id’ of the form to get the form object. For example, if the name of your form is ‘myform’, the JavaScript code for the submit call is: document.forms["myform"].submit(); But, how to identify a form? Give an id attribute in the form tag

Continue Reading →

How to get the value of a form element : check box and radio button

This is the third article in the getting form element values using JavaScript series. In this article we will see how to get the value of check box and radio button. Getting a radio element and it’s checked value Radio buttons in a form can be grouped together using the same name attribute, such that, if one of them is checked, all the others are automatically un-checked. Let us look at an example:

Continue Reading →

How to get the value of a form element : Drop downs and lists

This article is in continuation of getting form element values using JavaScript series. Drop down list We can obtain a reference to this type of element using its name: oSelectOne = oForm.elements["select_one_element_name"]; To get the index of the selected option in the JavaScript options array of the select element, we can use the selectedIndex property of the select element object: index = oSelectOne.selectedIndex; We can now use this index to determine the value of the selected option:

Continue Reading →

How to get the value of a form element using JavaScript

Please refer article: how to get JavaScript form object for information on getting a reference to the form object. In this article we demonstrate the use of JavaScript for accessing the values of form elements. Later, we will demonstrate all the concepts using a real world example. Text input element To obtain a reference to a text input element, here is some sample code: oText = oForm.elements["text_element_name"]; OR oText = oForm.

Continue Reading →

Using JavaScript to access form objects when there are multiple forms

In order to access a form through JavaScript, we need to obtain a reference to the form object. One obvious way to approach, is to use the getElementById method. For instance, if we had a form with the id attribute "subscribe_frm", we could access the form in this way: var oForm = document.getElementById('subscribe_frm'); However, this approach has the limitation that the <form> tag must have an id attribute, as the getElementById method needs the id of an element in order to locate it in the DOM tree.

Continue Reading →

Using JavaScript to reset or clear a form

Using an HTML ‘Reset’ button is an easy way to reset all form fields to their default values. For instance, the code snippet below shows an <input> field of type “reset”, which on being clicked resets all the form fields: <input type="reset" value="Reset Form"> In fact, we could also use the form’s reset() method to achieve the same effect, using a simple button element: <input type="button" value="Reset Form" onClick="this.form.reset()" /> These methods are very convenient to use, but they do not provide the functionality of clearing all the fields, including their default values.

Continue Reading →

The HTML Form Submit Button

The basics of an HTML form submit button is discussed first in this article, moving towards more advanced topics like multiple submit buttons. The code below creates a form submit button: <input type="submit" name="mysubmit" value="Click!" /> name: specifies the identification assigned to this submit button. value: is the label that appears on the button. Identifying the submit button on the server side The name and value of the button that is pressed to submit the form is passed to the server side script.

Continue Reading →