i need javascript for a textbox which allow only alphabet and first letter becomes capital on keyup..!!

any help will be appriciated..!!

thanks.!

Recommended Answers

All 4 Replies

document.getElementById("your id").onclick = function() {
var textbox=document.getElementById("your id");
textbox.value = textbox.value.toLower();
textbox.value = textbox.value.substring(1, textbox.value.length -1 ) + textbox.value.charAt(0).toUpper();

I'm not sure if that's perfectly correct, but this looks like homework so you should fix it yourself. :D

this code wil help u to check the text box for only letters..

if (!FormName.text.value.match(/^[a-zA-Z]+$/))
{
           alert("Please Enter only letters in text");
}

the expression in the If condition checks for only alphabets..

hey thank you very much SMVEC.........this one saved my day!!!!!!!!!!!!!!!!!!

hey thanks buddy....you saved my day

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.