|
-
Dec 20th, 2012, 05:54 PM
#3
Re: Failing Function With IF ELSE In It - Why Does It Fail?
Hi there alexdata
correct me if I am mistaken, but I think that you probably want this type of checking...
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>form check</title>
<style type="text/css">
#myform input[type=text] {
width:145px;
}
#myform textarea {
width:145px;
height:56px;
overflow:auto;
resize:none;
}
</style>
<script type="text/javascript">
(function() {
'use strict';
function init(){
var f=document.getElementById('myform');
var els=f.elements;
var mes=[];
for(var c=0;c<els.length;c++){
els[c].number=c;
mes.push(els[c].value);
els[c].onfocus=function(){
if(this.value==mes[this.number]) {
this.value='';
return;
}
}
els[c].onblur=function(){
if(this.value=='') {
this.value=mes[this.number];
return;
}
}
}
}
window.addEventListener?
window.addEventListener('load',init,false):
window.attachEvent('onload',init);
})();
</script>
</head>
<body>
<form id="myform" action="#">
<div>
<input type="text" value="your name">
<input type="text" value="your email">
<input type="text" value="captha answer">
<textarea rows="3" cols="3">your message</textarea>
</div>
</form>
</body>
</html>
Last edited by coothead; Dec 20th, 2012 at 05:59 PM.
Reason: spelling mistake
~ the original bald headed old fart ~
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|