iGeekiHackiMatt
07-01-2012, 04:23 PM
Hey, i am working on a "Quick Contact" e-mailer for a website and i would like to use JavaScript To Validate That Something has been entered into the textarea tags, here is my whole script of the test page (for validating NOT emailing i made)...(I do not need to validate the email with javascript i am use php for that and have already gotten it work)[also right now i am just using alert boxes, i should be able to switch it to forms by my self, but if you just want to put it in forms that would be fine, Thanks]
<html>
<head>
<title>Test1</title>
<script>
function Submit(){ /*alert('It is running the function');*/
var y;
y=document.getElementById('YN');
if (y =='Test...'){
alert('Please Give Your Name');
window.location = 'test1.php';
}
else {
if (y ==''){
alert('Please Give Your Name');
}
else {};
};
};
</script>
</head>
<body>
<textarea Name="YN" Id="YN" onfocus="if(this.value == 'Test...'){this.value = '';}" onblur="if(this.value == ''){this.value='Test...';}" rows="1" cols="20">Test...</textarea>
<input type="submit" onClick="Submit();" value="TEST" />
</body>
</html>
<html>
<head>
<title>Test1</title>
<script>
function Submit(){ /*alert('It is running the function');*/
var y;
y=document.getElementById('YN');
if (y =='Test...'){
alert('Please Give Your Name');
window.location = 'test1.php';
}
else {
if (y ==''){
alert('Please Give Your Name');
}
else {};
};
};
</script>
</head>
<body>
<textarea Name="YN" Id="YN" onfocus="if(this.value == 'Test...'){this.value = '';}" onblur="if(this.value == ''){this.value='Test...';}" rows="1" cols="20">Test...</textarea>
<input type="submit" onClick="Submit();" value="TEST" />
</body>
</html>