Button onclick action event : Button : Form JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Form » Button »

 

Button onclick action event

















<html>
<head>
<title>Matching a single literal character</title>
<script type="text/javascript" language="javascript">
<!-- //
function IsMatchingChar(str){
    var myRegExp = /a/;
    return myRegExp.test(str)
}

function TestGuess(){
    var guess = prompt("Enter a lower case character here","a");
    if (IsMatchingChar(guess)){
        alert("The correct answer was " + guess);
    }
    else{
        alert("Sorry " + guess + " doesn't match");
    }
}
// -->
</script>
</head>
<body>
<form>
<button type="Button" onclick="TestGuess()">Click here to guess</button>
</form>
</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Form
» Button