Solved

time validation

Posted on 2014-03-28
6
326 Views
Last Modified: 2014-03-28
Hi,

I have two fields first one is Date identified and the second is time occurred
I want to say if Date Identified has a value then Time occurred is required.

this is what I have that is not working.

Thanks,
Lulu

<INPUT style="TEXT-ALIGN: center; WIDTH: 175px; HEIGHT: 23px" id=DateIdentifiedtxt value=03/28/2014 name=DateIdentifiedtxt data-format="MM/dd/yyyy" jQuery110205894598305599419="43">
</INPUT >


<INPUT style="TEXT-ALIGN: center; WIDTH: 165px; HEIGHT: 23px" value=00:00:00 name=TimeOccurredTxt data-format="hh:mm:ss" jQuery110205894598305599419="62">
</INPUT >


function ValidateForm()
{
	var DateIdentified = $("#DateIdentifiedtxt").val();
	var TimeOccurred = $("#TimeOccurredTxt").val();
	
	if (DateIdentified != "" && (TimeOccurred === null || TimeOccurred === undefined || 
	TimeOccurred === '00:00:00'))
	{		
		alert("Time Occurred is required");
		return false;
	}
}

Open in new window

0
Comment
Question by:lulu50
  • 3
  • 2
6 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39962018
you should try to validate your HTML first : http://validator.w3.org/
0
 

Author Comment

by:lulu50
ID: 39962047
not sure what you mean by that

What is that link for? lol lol don't know what to do with it lol lol
ah I'm glad it's Friday.
0
 
LVL 2

Accepted Solution

by:
GowthamNatarajan earned 500 total points
ID: 39962254
Try this...

<INPUT style="TEXT-ALIGN: center; WIDTH: 175px; HEIGHT: 23px" id=DateIdentifiedtxt value=03/28/2014 name=DateIdentifiedtxt data-format="MM/dd/yyyy" jQuery110205894598305599419="43" onblur="return ValidateForm()">
</INPUT >


<INPUT style="TEXT-ALIGN: center; WIDTH: 165px; HEIGHT: 23px" value=00:00:00 id=TimeOccurredTxt name=TimeOccurredTxt data-format="hh:mm:ss" jQuery110205894598305599419="62" onblur="return ValidateForm()">
</INPUT >

function ValidateForm() {
            var DateIdentified = $("#DateIdentifiedtxt").val();
            var TimeOccurred = $("#TimeOccurredTxt").val();
            alert(DateIdentified + "--" + TimeOccurred);
            if (DateIdentified != "" && (TimeOccurred === null || TimeOccurred === undefined ||
            TimeOccurred === '00:00:00')) {
                alert("Time Occurred is required");
                return false;
            }
        }
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 82

Expert Comment

by:leakim971
ID: 39962262
What is that link for? lol lol don't know what to do with it

Put URL of your web page in the address field
0
 

Author Comment

by:lulu50
ID: 39962282
GowthamNatarajan,

When I put in a real time, it tells me that the time field is undefined.

not sure why
0
 

Author Closing Comment

by:lulu50
ID: 39962441
Thank you
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
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…

820 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