»
EnglishFrenchVietnamese

Print - Name Capitalization - JavaScriptBank.com

Full version: jsB@nk » Form » Textarea » Name Capitalization
URL: https://www.javascriptbank.com/name-capitalization.html

Name Capitalization © JavaScriptBank.comThis JavaScript will adjust capitalization of names (actually, the content of any form field you apply to it) so the first letter of each word is capitalized and the rest are lowercase. This is so easy to implement!

Full version: jsB@nk » Form » Textarea » Name Capitalization
URL: https://www.javascriptbank.com/name-capitalization.html



JavaScript
<script language="javascript">/*Created by: Will Bontrager | http://bontragerconnection.com/*/// Two values need to be specified, the form name and the //   field name to be processed.var FormName = "myform";var FieldName = "name";function CapitalizeNames() {  var ValueString = new String();  eval('ValueString=document.'+FormName+'.'+FieldName+'.value');  ValueString = ValueString.replace(/ +/g,' ');  var names = ValueString.split(' ');  for(var i = 0; i < names.length; i++) {    if(names[i].length > 1) {   names[i] = names[i].toLowerCase();   letters = names[i].split('');    letters[0] = letters[0].toUpperCase();   names[i] = letters.join('');  } else { names[i] = names[i].toUpperCase(); }  }  ValueString = names.join(' ');  eval('document.'+FormName+'.'+FieldName+'.value=ValueString');  return true;}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form name="myform">  Your name: <input type="text" name="name">  <input type="button" value="Click" onclick="return CapitalizeNames();"></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->