Jump to content

Time Check On Text Field Being Filled In Or Not


tomdelauro
 Share

Recommended Posts

Hi all,Im trying to create a check on a form i have built that basically prompts me to fill in a text field if there is nothing in the field by a certain time, so for example there is a text field for 9:30 and what i want is for a prompt to come up if nothing has been filled in by 9:30, so it has to be linked to the real time, any ideas, i really need help on this one, short deadline.Thanks Tommy D

Link to comment
Share on other sites

Hi Mate,Thanks for the reply, can you be a bit more specific as i am a begginer at coding, maybe give me some sample code of a text box and it being validated again a certain time, i.e. if 9:30 and text box = null show alert, i think if i had an example i would be able to work out how i can apply it to my form ?

Link to comment
Share on other sites

This doesn't do what you want, but you can easily adapt it. You'll want to explore the Date object a bit more:

<script type="text/javascript">	function start_timer () {		var d = new Date();		var t = d.getTime();		if (d < start_time + (1000 * 10 * 1) ) { // ten seconds			return;		}		var val = document.getElementById("my_input").value;		if (val == "") {			clearInterval(interval);			alert ("You must complete the text item.");		}	}	var interval;	var start_time; 	function init () {		var date = new Date();		start_time = date.getTime();		interval = setInterval (start_timer, 500);	}	window.onload = init;</script>*	 *	 *<label>Type something: </label><input type="text" id="my_input">

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...