hey,i jave this code. how to check the textbox (mname) to accept only letters?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<link rel="stylesheet" type="text/css" href="mystyle.css" /> <!--- call my style -->
<head>
<title>Home page -  MidermFaill2015 - Andreas Petrou</title> <!--- title of page -->
<!--Andreas Petrou 8600-->
</head>
<body>
<!------------------------------------------------------------->

<script type="text/javascript">
<!--Script for check is empty-cells-->
function val(){
    var str = document.forms["form1"]["mname"].value;
    if (str == null || str == "") {
        alert("Please enter your NAME for go to the next page:");
        return false;
    }

}

<!--Script for check is empty-cells-->
function surname(){

var sts = document.forms["form1"]["sname"].value;
    if (sts == null || sts == "") {
    alert("Please enter your SURNAME for go to the next page:")
    return false;
    }


}
<!--Script for check is empty-cells-->
function secword(){

var stf = document.forms["form1"]["sword"].value;
    if (stf == null || stf == "") {
    alert("Please enter your SECRET WORD for go to the next page:")
    return false;
    }


}
<!-- check the secret word---------->
function ch(){
var rts= "abc1"// the true secret
var stx = document.forms["form1"]["sword"].value;
 if (stx == rts) // check the secret true
 {
  alert("your SECRET is true") // the message is true the secret word
  return true;
 }
else

alert("Please try another SECRET word") // the message is flase the secret word
stx == null;

return false;


}

<!---------- clear the form ---------- >
function clearLs() {
form1.reset(); // Clear all data in form

}
<!------------------------------------>



  </script>

<!------------------------------------------------------------>

 <!--Main page-->
 <p>Welocome to first page</p>
 <p>Click to the enter side button to continue</p>
 <p>***Please fill the textboxs***</p>

 <tr>
<!--Form to netxt and functon call-->
<form name="form1" action="step2.php" onsubmit="return val(),surname(),secword(),ch()" method="post" >
Name:        <td><input type="text" name="mname" size="20" maxlength="12" value="" /> <br/></td>  <!--- Name textbox-->
Surname:     <td><input type="text" name="sname" size="20" maxlength="12" value="" /> <br/></td>  <!--- Surname textbox-->
Secret Word: <td><input type="text" name="sword" size="20" value="" /> <br/></td>  <!--- Secret word  textbox-->
</tr>
  <!--Button to next-->
<input type ="submit"  value="Enter Side"  />
<input type="button" value="Clear" onClick="clearLs()"/> <!---- clear all date in form -->

</form>
</body>
</html>

This is not Java code, this is JavaScript code. If you think they are the same, it's a bit as saying a Car is the same as a Carpet

Anyway, have you tried applying a regex validation?

meaning ... what, exactly? what have you tried, and what is going wrong?
your description of the problem is pretty vague.

Could you show us exactly what you try, where (and when) during the flow it goes wrong, and in which way it goes wrong?

This article has been dead for over six months. Start a new discussion instead.