[Javascript] (no subject)

Scott Hamm linuxgold at gmail.com
Wed Nov 2 09:42:25 CST 2005


Hi all.  I'm new to this mailing list and  I'm ASP/SQL application
developer.  I've been using SQL stored procedure to do error
corrections until I realize that it created high traffic between ASP
and SQL so I decided to learn javascript.

What I need for my web to do is to ensure that khrs have '0' or more
and is numeric and/or if kpto is more than '0' and is numeric AND sum
of khrs and kpto MUST not exceed 8 hours.  I do not want both kph and
kpto to have '0' values at same time either.  So I created this
script, everything works up to kph+kpto and I've been struggling to
figure out why.

Thanks for your help in advance.

Scott
[code]
	function validateKronos()
	{
		digits="0123456789."
		if(krono_process.assocID.options[0].selected)
		{
			alert("Associate is not selected")
			krono_process.assocID.focus()
			return false;
		}
		else
		{
			var kph=krono_process.khrs.value
			len=kph.length
			if(len==0)
			{
				alert("Hours is not indicated. Enter 0 if no hours worked.")
				krono_process.khrs.focus()
				return false;
			}
			else
			{
				for(i=0;i<len;i++)
				{
					if(digits.indexOf(kph.charAt(i))<0)
					{
						alert("Hours must be numeric")
						krono_process.khrs.focus()
						return false;
					}
				}
				var kpp=krono_process.kpto.value
				len=kpp.length
				if(len!=0)
				{
					for(i=0;i<len;i++)
					{
						if(digits.indexOf(kpp.charAt(i))<0)
						{
							alert("PTO must be numeric")
							krono_process.kpto.focus()
							return false;
						}
					}
					var kptot=krono_process.kpto.value
					var khtot=krono_process.khrs.value
					ktot=kpp+kph
					If(ktot>8)
					{
						alert("Exceeding 8 hours total to use PTO")
						krono_process.khrs.focus()
						return false;
					}
				}
			}
		}
	}
[/code]
--
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html



More information about the Javascript mailing list