Changing to lower case letter of text box data with onBlur event

WE can change the case of entered text inside a text box. We can change the text to all uppercase or to all lower case letters as per the requirements. This is done in case of entering user ids in login forms were all ids are stored in either lower case or upper case letters. If user ids are stored as lower case letters then before comparing we need to convert entered id to lower case and show it to the user that this is the case thy have to enter. For example if some one entered user id as John then it is to be converted as john inside the text box.
We will trigger a function in JavaScript were the function toLowerCase() will be used to convert the uppercase letter to lower case text. This function will be trigged by the onBlur event handler of the text box. This is the text box code we ill use inside the form where we have kept some default text also.

<input type=text name=type value=''Enter USER ID'' onBlur="change_case();">
Now when ever the curser moves out of the text box ( we call it onBlur ) the event handler will trigger the function change_case. Inside this function change_case we will change the value to lower case by using toLowerCase function.

demo of the text box onBlur event.

Here is the complete code.
<html><head>
<title>Demo onBlur textbox input</title>

<script type="text/javascript"> 
function change_case()
{
document.form1.type.value=document.form1.type.value.toLowerCase();
}
</script>

</head>
<body  onLoad="form1.type.focus();">

<form name=form1 method=post action=''''>
<input type=text name=type value=''Enter USER ID'' onBlur="change_case();">
<input type=submit value=Submit> </form>

</body>
</html>
OnBlur event is used to convert any input value in meter to Feet ( and vice versa )
Feet to Meter and vice versa

OnBlur event is used to convert inches to cm ( and vice versa )

Inches to CM and vice versa
Event Handling onKeyPress Mouse event Textarea onClick event onKeyDown Mouse event
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer