I have this code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>sss</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type='text/javascript'>
function isAlphabet(obj){
var alphaExp = /[^a-z0-9_-]+/;
if(!obj.value.match(alphaExp)){
return true;
}
else{
alert('the bad symbols');
obj.focus();
return false;
}
}
</script>
</head>
<body>
<form action="/">
<input type='text' id='letters' onblur="isAlphabet(this)"/>
</form>
</body>
</html>
And I want to show an Alert()
displaying only those characters for which validation fails.
For example :
If an input contains symbols like " #abc " , the Alert Message should show only "#". How can this be done?