truil
PvP Gladiator
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
In this tutorial we will create a Automatically Change Text Properties using JavaScript. This code can change the text properties into Upper or Lower Case. The code use onkeyup to automatically change the text properties into upper or lower case using toUpperCase() or toLowerCase() special function. This is a user-friendly program feel free to modify it.
We will use JavaScript to add some new feature to the website interface by actually written into an HTML page. It is what gives your page a different interactive elements and animation that engage a user.
Getting Started:
This is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.
The Main Interface
This code contains the interface of the application. To create this just write these block of code inside the text editor and save this as index.html.
Creating the Script
This code contains the script of the application. This code will automatically change the text into upper or lower case when inputted. To do this just copy and write these block of codes as shown below inside the text editor and save it as script.js inside the js directory
There you have it we successfully created a Automatically Change Text Properties using JavaScript. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!
Download
We will use JavaScript to add some new feature to the website interface by actually written into an HTML page. It is what gives your page a different interactive elements and animation that engage a user.
Getting Started:
This is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.
The Main Interface
This code contains the interface of the application. To create this just write these block of code inside the text editor and save this as index.html.
- <!DOCTYPE html>
- <html
lang
=
"en"
>
- <head
>
- <meta
charset
=
"UTF-8"
name
=
"viewport"
content
=
"width=device-width, initial-scale=1"
/
>
- <link
rel
=
"stylesheet"
type
=
"text/css"
href
=
"css/bootstrap.css"
/
>
- </
head
>
- <body
>
- <nav class
=
"navbar navbar-default"
>
- <div
class
=
"container-fluid"
>
- <a
href
=
"https://sourcecodester.com"
class
=
"navbar-brand"
>
Sourcecodester</
a
>
- </
div
>
- </
nav>
- <div
class
=
"col-md-3"
></
div
>
- <div
class
=
"col-md-6 well"
>
- <h3
class
=
"text-primary"
>
JavaScript - Automatically Change Text Properties</
h3
>
- <hr
style
=
"border-top:1px dotted #ccc;"
/
>
- <center
><h1
>
UPPERCASE</
h1
></
center
>
- <div
class
=
"col-md-4"
>
- <div
class
=
"form-group"
>
- <input
type
=
"text"
class
=
"form-control"
onkeyup
=
"changeToUpper(this.value)"
placeholder=
"Enter here..."
/
>
- </
div
>
- </
div
>
- <div
class
=
"col-md-4"
>
- <div
class
=
"form-group"
>
- <input
type
=
"text"
class
=
"form-control"
id
=
"all_upper"
readonly
=
"readonly"
/
>
- </
div
>
- </
div
>
- <div
class
=
"col-md-4"
>
- <div
class
=
"form-group"
>
- <input
type
=
"text"
class
=
"form-control"
id
=
"first_upper"
readonly
=
"readonly"
/
>
- </
div
>
- </
div
>
- <br
style
=
"clear:both;"
/
>
- <center
><h1
>
LOWERCASE</
h1
></
center
>
- <div
class
=
"col-md-4"
>
- <div
class
=
"form-group"
>
- <input
type
=
"text"
class
=
"form-control"
onkeyup
=
"changeToLower(this.value)"
placeholder=
"Enter here..."
/
>
- </
div
>
- </
div
>
- <div
class
=
"col-md-4"
>
- <div
class
=
"form-group"
>
- <input
type
=
"text"
class
=
"form-control"
id
=
"all_lower"
readonly
=
"readonly"
/
>
- </
div
>
- </
div
>
- <div
class
=
"col-md-4"
>
- <div
class
=
"form-group"
>
- <input
type
=
"text"
class
=
"form-control"
id
=
"first_lower"
readonly
=
"readonly"
/
>
- </
div
>
- </
div
>
- </
div
>
- </
body
>
- <script
src
=
"js/script.js"
></
script
>
- </
html
>
Creating the Script
This code contains the script of the application. This code will automatically change the text into upper or lower case when inputted. To do this just copy and write these block of codes as shown below inside the text editor and save it as script.js inside the js directory
- function
changeToUpper(
string)
{
- if
(
string==
""
)
{
- document.getElementById
(
'all_upper'
)
.value
=
""
;
- document.getElementById
(
'first_upper'
)
.value
=
""
;
- }
else
{
- document.getElementById
(
'all_upper'
)
.value
=
string.toUpperCase
(
)
;
- document.getElementById
(
'first_upper'
)
.value
=
UpperCaseFirstLetter(
string)
;
- }
- }
- function
changeToLower(
string)
{
- if
(
string==
""
)
{
- document.getElementById
(
'all_lower'
)
.value
=
""
;
- document.getElementById
(
'first_lower'
)
.value
=
""
;
- }
else
{
- document.getElementById
(
'all_lower'
)
.value
=
string.toLowerCase
(
)
;
- document.getElementById
(
'first_lower'
)
.value
=
LowerCaseFirstLetter(
string)
;
- }
- }
- function
UpperCaseFirstLetter(
string)
{
- return
string[
0
]
.toUpperCase
(
)
+
string.slice
(
1
)
;
- }
- function
LowerCaseFirstLetter(
string)
{
- return
string[
0
]
.toLowerCase
(
)
+
string.slice
(
1
)
;
- }
There you have it we successfully created a Automatically Change Text Properties using JavaScript. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!
Download
You must upgrade your account or reply in the thread to view hidden text.