Post Method Not giving Alerts like planned?

Posted by Charles on Stack Overflow See other posts from Stack Overflow or by Charles
Published on 2009-08-07T21:18:38Z Indexed on 2010/12/25 9:54 UTC
Read the original article Hit count: 258

Filed under:
|
<form action="" method="post">
<div align="center"><legend>Add a Code</legend>
<label for="code"></label>
<input type="text" name="code" id="code" maxlength="10" />
<input type='button' 
 onclick=
             "isAlphanumeric(document.getElementById('code'),'Your Submission Contained Invalid Characters'); 
              isBadPhrase(document.getElementById('code'), 'Please Enter A Correct Friend Code!');"     
     value='Check Field' />

function isAlphanumeric(elem, helperMsg){
var alphaExp = /^[0-9a-zA-Z]+$/;
if(elem.value.match(alphaExp)){
	return true;
}else{
	alert(helperMsg);
	elem.focus();	
	return false;
}

}

function isBadPhrase(elem,helperMsg){
var badPhrase=/EPW|ESW|\s/;
if (elem.value.match(badPhrase)){
	alert(helperMsg);
	elem.focus();
	return false;
}else{
	return true;
	}

}

What is wrong here?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about post