
I want to Write only the word A-Z in a text box What is the code?

<html>
<script>
function checkString(text) {
if(isNaN(text)){
return 1;
}
else{
alert("Please enter a valid string. The only characters accepted are A - Z and a - z");
return 0;
}
}
function validate(){
if(document.form.st.value == ""){
alert( "Please enter string." );
document.form.st.focus();
return false;
}
if(checkString(document.form.st.value)==false){
document.form.st.focus();
document.form.st.value ="";
return false
}
return true;
}
</script>
<form name="form" method="post" onsubmit="return validate();">
Enter Name: <input type="text" name="st"><br>
<input type="submit" value="Add" name="button">
</form>
</html>

<html>
<script>
function checkString(text) {
if(isNaN(text)){
return 1;
}
else{
alert("Please enter a valid string. The only characters accepted are A - Z and a - z");
document.getElementById("st").focus();
document.getElementById("st").value ="";
return 0;
}
}
</script>
Enter Name:   <input type="text" id="st" onkeyup="checkString(this.value);">
</html>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.