Tutorial: Fill an input field with the current date and time with javascript
Save time for your self, and let javascript give you the current time.
Tutorial Details:
We have a customer that enters lots of articles through a form, and one of the fields are a date/time when the auction is to start. To speed up their work I created a handy function that fills the input field with the current date/time.
Lets set the id of the input field to "startWhen", by writing this:
This way we can access that field with this function: document.getElementById("startWhen")
Let's assign the result from that function as the variable "theInput".
The variable has a number of different attributes and the most important for us right now is .value, which holds the text that is displayed in the field.
Ok, let's look at the "action... the javascript function: "setStartTimeNow()".
Basicly we get a "date-object" like this: var d = new Date();
That object have lots of functions for getting the different variables like year, month, hour etc.
Important for us (that made me rub my head a little...) is that the function getMonth() returns a number between 0 and 11, where 0 is january and 11 is december.
So I add 1 to the the month, so we get the "normal" way to write month...
Because I live in Sweden I write the date/time like this: 2006-06-04 23:19.
Feel free to change around with the formatting if you need to.
There is some more "magic" to get the format good looking.
Numbers less than 10 are returned without a leading zero, but I like to have a leading zero for the format.
So this short way to write a if makes sure that numbers lover than 10 get's a zero infront of the number: (currMonth < 10 ? "0" : "")
I now create a link that activates the javascript function: Set current time It's called by using the "onclick" event.
A Generic MVC Model in Java
A Generic MVC Model in Java
Model-View-Controller (MVC) is a widely used design pattern, especially popular in graphical user interface (GUI) programming. JDK 1.5 introduces parameterized types, or generics. Combining the two allows for a generic imple
JSP date example
JSP date example
JSP Date Example
Till now you learned about the JSP syntax, now I will show you how to create a simple dynamic JSP page that prints the current date and time. So the following code accomplish this:
<%@page contentType="text/html"
Submit a Request for a Project to be done
Submit a Request for a Project to be done
Fill this form to Submit a Request for a Project to be done.
User's Personal Details
Name :
Address:
Email:
Project Name:
Project Description
Language to be used:
Delivery Date:
Client Side Address Validation in Struts
Client Side Address Validation in Struts
Client Side Address Validation in Struts
In this lesson we will create JSP page for entering the address and use the functionality provided by Validator Framework to validate the user data on the browser.
Struts Validator Framework Tutorial with Example
Struts Validator Framework Tutorial with Example
Struts HTML Tags
Struts Validator Framework
This lesson introduces you the Struts Validator Framework. In this lesson you will learn how to use Struts Validator Framework to validate the user