Solved

Javascript validation

Posted on 2014-04-01
2
119 Views
Last Modified: 2014-04-03
I want to validate this format 04/01/2014 01:30 if its type in and submitted.
0
Comment
Question by:smares323
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
Mrunal earned 500 total points
ID: 39971852
hi
please refer below code:

http://jsfiddle.net/8m63c/

<form>
    <p>Enter date</p>
    <input type="text" id="test1" value="02/05/2013 11:23"/>        
    <br /><br />
    <input type="button" id="btnSubmit" value="Submit" />
</form>

Open in new window


    $('#btnSubmit').click(function(){
        if(validateDate($('#test1').val())) {
            $('#test1').css('background', '#0F0');
        } else {
            $('#test1').css('background', '#F00');
        }
    });


function validateDate(testdate) {
    //alert(testdate);
    var date_regex = /^\d{2}\/\d{2}\/\d{4}[ ]\d{2}[:]\d{2}$/ ;
    return date_regex.test(testdate);
}

Open in new window

0
 

Author Closing Comment

by:smares323
ID: 39976938
great advice
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question