function cekspam(cText) {
	var aTexts=new String(cText);
	var nLens =aTexts.length;
	var newTexts="";
	for (var i=0;i<=nLens-1;i++) {
	  if (aTexts.charAt(i)=="/") { newTexts="~";}else{
			newTexts=newTexts+aTexts.charAt(i);
		}
	}
	return (newTexts)
}

function leftText(cText,nLen) {
	var aText=new String(cText);
	var newText="";
	for (var i=0;i<=nLen-1;i++) {
	    newText=newText+aText.charAt(i);
	}
	return newText;
}

function checkemailp() {
  var str=document.formmember.emailp.value
  var filter=/^.+@.+\..{2,3}$/
     if (filter.test(str))
       testresults=true
	 else {
       testresults=false
}
 return (testresults)
}

function checkemail() {
  var str=document.formmember.email.value
  var filter=/^.+@.+\..{2,3}$/
     if (filter.test(str))
       testresults=true
	 else {
       testresults=false
}
 return (testresults)
}

function validate(isForm){

isValid = true;
if (isForm.namap.value == "")
{
alert("Mohon masukan nama Anda!");
isForm.namap.focus();
isValid = false;
}
if (isValid)
{
if (isForm.emailp.value == "")
{
alert("Mohon masukan email Anda!");
isForm.emailp.focus();
isValid = false;
}
}
if (isValid)
{
if (!checkemailp())
{
alert("Mohon masukan email Anda dengan benar!");
isForm.emailp.focus();
isValid = false;
}
}

if (isValid)
{
if (isForm.nama.value == "")
{
alert("Mohon masukan nama teman Anda!");
isForm.nama.focus();
isValid = false;
}
}
if (isValid)
{
if (isForm.email.value == "")
{
alert("Mohon masukan email teman Anda!");
isForm.email.focus();
isValid = false;
}
}
if (isValid)
{
if (!checkemail())
{
alert("Mohon masukan email teman Anda dengan benar!");
isForm.email.focus();
isValid = false;
}
}

if (isValid)
{
if (isForm.pesan.value == "")
{
alert("Mohon masukan pesan untuk teman Anda!");
isForm.pesan.focus();
isValid = false;
}
}

if (isValid)
{
if (leftText(cekspam(isForm.pesan.value),1) == "~")
{
alert("Mohon isi pesan tidak mengandung tanda '/'!");
isForm.pesan.focus();
isValid = false;
}
}

if (isValid){isForm.submit()}
}

function checkemailp() {
  var str=document.formmember.emailp.value
  var filter=/^.+@.+\..{2,3}$/
     if (filter.test(str))
       testresults=true
	 else {
       testresults=false
}
 return (testresults)
}

function checkemailComment() {
  var str=document.formmember3.commentEmail.value
  var filter=/^.+@.+\..{2,3}$/
     if (filter.test(str))
       testresults=true
	 else {
       testresults=false
}
 return (testresults)
}

function validate3(isForm){

isValid = true;
if (isForm.commentName.value == "")
{
alert("Mohon masukan nama Anda!");
isForm.commentName.focus();
isValid = false;
}
if (isValid)
{
if (isForm.commentEmail.value == "")
{
alert("Mohon masukan email Anda!");
isForm.commentEmail.focus();
isValid = false;
}
}
if (isValid)
{
if (!checkemailComment())
{
alert("Mohon masukan email Anda dengan benar!");
isForm.commentEmail.focus();
isValid = false;
}
}

if (isValid)
{
if (isForm.commentMessage.value == "")
{
alert("Mohon masukan komentar Anda!");
isForm.commentMessage.focus();
isValid = false;
}
}

if (isValid)
{
if (leftText(cekspam(isForm.commentMessage.value),1) == "~")
{
alert("Mohon isi komentar tidak mengandung tanda '/'!");
isForm.commentMessage.focus();
isValid = false;
}
}

if (isValid){isForm.submit()}
}
