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. Here is the complete code.
<title>Demo onBlur textbox input</title>

<script type="text/javascript"> 
function change_case()

<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>

OnBlur event is used to convert any input value in meter to Feet ( and vice versa ) OnBlur event is used to convert inches to cm ( and vice versa )
Visitors Rating
Your Rating


Post Comment This is for short comments only. Use the forum for more discussions.

HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 All rights reserved worldwide Privacy Policy Disclaimer