Possible en double:
Post Method Not giving Alerts like planned?ne fonctionne pas
Javascript:
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 isGoodPhrase(elem,helperMsg){
var badPhrase=/EPW|ESW|\s/;
if (elem.value.match(badPhrase)){
alert(helperMsg);
elem.focus();
return false;
} else {
return true;
}
}
function checkInput(id) {
return isAlphanumeric(document.getElementById(id),'Your Submission Contained Invalid Characters')
&& isGoodPhrase(document.getElementById(id), 'Please Enter A Correct Friend Code!');
}
</script>
et HTML
<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="return checkInput('code');" value='Check Field' />
</form>
</div>
double: http: //stackoverflow.com/questions/1247065/post-method-not-giving -alerts-like-planned –
Oh ... et il n'y a pas non plus de 'question' ici. –
Ce n'est pas une question – spender