Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 30th, 2007, 01:59 AM
Authorized User
 
Join Date: Feb 2006
Posts: 63
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Hannibal
Default javascript datetime validation


Hi..

I have a javascript datetime picker calendar and a textbox in my web application. The user selects the datetime picker and uses the tab continuously. so at one point of time, there is no focus on the calender pick. Then the user clicks the enter button. The data which appears in the textbox is like this at this point of time: /11/2007 11:12:59

As you can see, the date is not present(only the month,year and the time is present).. I want to validate this.

How to check if the date time entered in the textbox is in proper format through javascript?

Please help





 
Old December 5th, 2007, 06:39 AM
Authorized User
 
Join Date: Feb 2006
Posts: 63
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Hannibal
Default

Hi..

After a long time, I have the reply..
Thanks to ASP.NET Forum

var ctrl = document.getElementById('<your_textbox_clientID>') ;

var v = ctrl.value;

if (v.replace(/^\\s+|\\s+$/, '').length != 0 && isNaN(Date.parse(v))) {
      alert('Invalid value!');
      ctrl.focus();
      return false;
}








Similar Threads
Thread Thread Starter Forum Replies Last Post
using javascript for server control validation swagatika ASP.NET 1.0 and 1.1 Basics 3 December 20th, 2005 08:38 AM
Easy Ques -- Datetime validation for Access bekim Access 2 June 16th, 2005 01:52 PM
Javascript validation for apostrophe crmpicco Javascript How-To 2 March 2nd, 2005 06:57 AM
JAVASCRIPT input validation ! Please help ! sammes Javascript 2 July 19th, 2004 10:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.