Solved

time validation

Posted on 2014-03-28
6
327 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
[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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
Handling case and special names in javascript 3 52
jQuery menu problem in an older browser 6 33
Multiple of Image Swaps 5 42
asp.net mvc5 6 34
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses

752 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