We would like to know how to check for a special character at the beginning a string.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='https://ajax.googleapis.com/ajax/libs/prototype/1.7.1/prototype.js'></script>
<script type='text/javascript'>
var str="%*hkfhkasdfjlkjasdfjkdas";
if(str.indexOf("%") === 0|| str.indexOf("*") === 0){
document.writeln("true");
}<!--from w w w. j a v a 2s . com-->
else{
document.writeln("false");
}
</script>
</head>
<body>
</body>
</html>
The code above is rendered as follows: