Professional Documents
Culture Documents
Javascript Bangla Tutorials PDF
Javascript Bangla Tutorials PDF
• яskp Syntax
• яskp Enable
• яskp Location
• яskp External
• яskp Operator
• яskp Variable
• яskp Function
• яskp Event
• яskp Statement
• If Statement
• Else If Statement
• While Loop
• For Loop
• Comments
• яskp Array
• яskp Alert
• яskp Confirm
• яskp Prompt
• яskp Print
• яskp Redirect
• яskp Popup
• яskp Date
• яskp
• яskp s
• яskp s
• яskp s sp
яskp u
| ( Javascr i pt Tut or i al i n Bangl a)
:
e! e !"# ! я$ " p &' &।ei я$ " ! яstp।яskp +
e kin i. skp
$# я & buя skp।
kin i. skp
$# я e a1 + c 3 o 5& buя & " buя ei skp$#
run/execute &।kin i. e
&67" +
i., i.
$# я $#
. o & e 8 execute/run +5।яstp e p8! #&8
+
e 8 я
i
e p" 9! :; e 35।
p5 6A&:n ei u
'## $ 6! a&'i eiee
m n
я! " + &।
яskp
$
%
& ' ( Javascr i pt Synt ax Tut or i al i n Bangl a)
:
1. script
$ &&+ buя &I " + & 3 6! яskp &&+ F!।
F।
01.<html>
02.<body>
03.<script type="text/JavaScript">
04.<!--
05.document.write("Hello World!")
06.//-->
07.</script>
08.</body>
09.</html>
p'!:
Hello world!
document.write:
script e '9 86 + c '! e &&+ 3 ! document.write ।যার 8 text, HTML a1& Ji
3। ei '! e e
&" text string &&+ F 3 "Hello World!" ! 6"। e buя e
p'" + &।
SYNTAX $ 6h:
6h:
u6 яstp .
k
" 6 &! 3 "document.write(Hello World!)" ei statement e ' 9 !
! !i। ! p " statement e '9 ! ' " яstp e
! e p я! !i।
" & 6! 3 aj pg + 1 ! " & k t &&+ " 6 !। " &
! &&+ я#7 3! e
i ! # statement ( # document.write statements )
।
яskp 0 i?
-
i?
- ek
p-
ek
p- e 96
,d&:
,d&:
Internet Explorer 6/7 e 6! security setting e $ check " 6 ! 3 6! яstp
F
!। ! яstp
u6 +
।
1 p1 Tools menu " Click " + &
2 "6 menu + " Internet Options !&! " + &
3 Internet Options e Security tab e Click " + &
4 "6 Custom Level &
! Click security settings e p &' " + &
5 Scroll Scripting section e 3 " + &
6 script
я! Enable &
! Select " + &
7 pk mn " OK &
! Click " + &
8 я! Yes &
! Click " + &
яskp 0 EEk-
EEk- e 96
,d&:
,d&:
Firefox 2 e 6! Options e Content setting e $ check " 6 ! 3 6! яstp
F
!। ! яstp
u6 +
।
1 p1 Tools menu " Click " + &
2 "6 menu + " Options !&! " + &
3 Options e Content tab e Click " + &
4 !Y" #! 3 Enable JavaScript check box e F !
5 pk mn " OK &
! Click " + &
яskp 0 a
, – 0& 96
,d&:
,d&:
Opera " 6! Preferences e Content setting e $ check " 6 ! 3 6! яstp
F
!। ! яstp
u6 +
।
1 p1 Tools menu " Click " + &
2 "6 menu + " Preferences !&! " + &
3 Preferences e Advanced tab e Click " + &
4 & 6 '
s item + " Content !&! " + &
5 !Y" #! 3 Enable JavaScript check box e F !
6 pk mn " OK &
! Click " + &
&+\s (External) яskp i e& " &&+ 6&" a8 ! + F ।
$':
$':s $ ek-R
яskp Ei
( Ext er nal JavaScr i pt Fi l e Tut or i al i n
Bangl a)
:
$':
$':s ( EXTERNAL) яskp Ei
i
,R -:
-:
external яskp file Import I
#k я। p1" 3 i
Import &!
&8 e& '#8# t яskp
file + " + &।d"7" i
extension a&'i ".js" + " + & ।পরিশেষে 6! a&'i file e a&s! я! " + &।
8 3 "myjs.js" ! e file F 3 e
i ! Hello World ! alert function 8!
F।o 8 3 HTML file e& яskp file ei directory " F।
myjs.js ! яskp file :
1.function popup() {
2.alert("Hello World")
3.}
01.<html>
02.<head>
03.<script src="/myjs.js">
04.</script>
05.</head>
06.<body>
07.<input type="button" onclick="popup()" value="Click Me!">
08.</body>
09.</html>
p'!:
F# Tips:
1 6! 3 ei Script &n 6 я &&+ " ! "+
external яskp file &&+ " 6 !।e
ei .
p " 6 я я!
p я! !i।
2 u 8 ! Script e я! external яskp file &&+ 3 3! e!
i6 3 head tag (functions) e
+
i6 3 body tag e +।
3 6! !Y" " + & 3 external яskp file e <script> tag an#k + & !। ! '#8# t HTML
comment e& яskp code Fa F# 1 & !।
яskp a,
u
( JavaScr i pt Oper at or Tut or i al i n
Bangl a)
:
+ 3$ 2+44
- & $ 6-22
* $#! 7*44
/ $ 15/3
15 3
% .#
43%
43 10
яskp a,
e 0
$
9' uP'-:
uP'-:
! e
8! u+! +
3 !
6$!"7 3 mn + F ।
01.<body>
02.<script type="text/JavaScript">
03.<!--
04.var two = 2
05.var ten = 10
06.var linebreak = "<br />"
07.
08.document.write("two plus ten = ")
09.var result = two + ten
10.document.write(result)
11.document.write(linebreak)
12.
13.
14.document.write("ten * ten = ")
15.result = ten * ten
16.document.write(result)
17.document.write(linebreak)
18.
19.document.write("ten / two = ")
20.result = ten / two
21.document.write(result)
22.//-->
23.</script>
24.</body>
p'!:
two plus ten = 12
ten * ten = 100
ten / two = 5
&
+
e
p"7 (symbolic) ! 3 6! ! ;
# u6s6! । &
e
e u d' + c 6!
"1 я 3 " 6! 6&" " " &&+ " 6 !। &
!
! 3 e
&я & $ 1 "#
!
"+
ei & $ &я .
(data) 1
1 "#
! 3। Variable ! ( name) d .
a ! 1 3 " 6!
+ я e
move " 6 !।
" 6 !।
&
e u+!:
u+!
p1& &
&&+ k t &
! 6# & "var"
я#7 ! " &
programming practice e я!
p1& &
! 6# & "var"
u"।! u+ ! 8 &9 6s +
।
01.<body>
02.<script type="text/JavaScript">
03.<!--
04.var linebreak = "<br />"
05.var my_var = "Hello World!"
06.
07.document.write(my_var)
08.document.write(linebreak)
09.
10.my_var = "I am learning JavaScript!"
11.document.write(my_var)
12.document.write(linebreak)
13.
14.my_var = "Script is Finishing up..."
15.document.write(my_var)
16.//-->
17.</script>
18.</body>
p'!:
Hello World!
I am learning JavaScript!
Script is Finishing up...
u6 u+ ! # &
"7 F 3 e
i! b я! HTML 8 F a6 + c .i! &
3 u6 script e 8 "! n 8 !
# F।
&
e
# ! ; " ! h (=) &&+ " + &। 3 ! & 6 ' 1 & &
e& .! 6 ' 1 & &
e
#। 3! my_var = "Hello World!" e ! + c my_var ! "Hello World!" । &
e& e
#
& ! order h " + & a1Z p1 &
e ! 6 &
e
# " ! +
script h" я & !।
яskp 0
$
-
--W&:
--W&:
3! 6! &
! ( name)6Fn
6Fn &! "! a&'i
k " + & ! 3! яskp ereserve
e ! !
+। &
! (name)6F n
6F n
practice +
&d!i
! &&+ 3! ! &
# e 1 ! '
। 3! 8#! 6! &
# я#" iя ! ' F k t &
! " 6 ! "shoe_size"। 3 #&
+ я 6a e& &I 3 &।
яskp &
! (0 3! 7lucky, 99bottle e& 3charm ।
0-99) '## + & !। 3 &&+ &8 !। 3!:
&
+ &
! F
+ " &d '## e& &
! ! 3 e a8 'b &'s + "+
'b$#
underscore 6:1 " +। 3!:
+। 3! my_var, strong_man, happy_coder i"।
3 6! ! pg e aj" 1 "+
ei a8 ' "
$ &। a!! pg
$# я (,
++,6ei6 i") '! e " яskp e '! pi ei। e 3 6! '! ' p1& + 1 "+
ei
a8 #& ! 3$ + 6a u"।
E[\- ?
?
'! +
e
# . 3 #p a&s 1 3"kd 63n ! " я " &
+। 6#!&:t я k t '! a !
&n । '! e 8 ei . & & !
ei я & & 3 ।
яskp '! e u+!:
u+!
'! eiee
.k n e head
$ e " u"। '! "7 #& +я। p1 '! e ! " + &
"6 8! яskp .
" + & ।নিচে u+ ! 8 &9 6s +
।
01.<html>
02.<head>
03.<script type="text/javascript">
04.<
05.function popup() {
06.alert("Hello World")
07.}
08.>
09.</script>
10.</head>
11.<body>
12.<input type="button" onclick="popup()" value="popup">
13.</body>
14.</html>
p'!:
'! 1
8 browser &#I F 3 '! &&+ " 3c। "6 '! e ! F 3 "
e
6&" " &&+ " 6। 3 +"# pop up alert "7 F
ei '! "popup" '! &
. "
6। ei "{,}" b
'! . e 7! !8! ।
popup '! e . ei b
"
+
।
8!" e
&9 e
$ " 6 3 & popup '! e " alert '! &&+
। ei
alert '!
popup box + p'! ।e
i +
'! &&+ & &a &9 " +
'! e "
'! e &&+ ।উপরের u+ ! F &
! click
popup box F । &
! click event &
।
e &9 6&" a8
! + F ।
яskp i
? u
( JavaScr i pt Event Tut or i al i n Bangl a)
:
яskp &9 6 '7"
&6 + c e k" d 6! .i! o & 6я " +3 & ।
6! i
я
e !
p!&n , ! & я7&n ! + &। 9!7 o & 6я "7 t + c яskp i n । яskp e
i n +
e! e я! 3 o & 6я e 1 & e u6 F#
।নিচে яskp i n e F# u+! +
।
1 e u k
2 o & 6я
. +o
3 h" s ! u6 u 3 hover ! я! ।
4 eiee
e i!6#
&k
k
5 e keystroke
яskp i ns e u+!:
u+!
яskp e F# 6#& !8" ! F 3 8 a ! i n
u6 "
s + F। 6! 3! i n ! ;
&! "! F# я " +। 6! a&'i i n ! ; " + & ! HTML element i n e я! a 6k
& e& i n
1 1 function я & ।
яskp 0s
? 0s
? u
( JavaScr i pt St at ement Tut or i al
i n Bangl a)
:
6! ic" яskp .
" 6 ! " & &' $ k t яskp .$#
6:1 6:1 s
n & &&:" d $h" ।
e s
n &
" 6 3
# ! । e s
n '!
" 6 । s
n ! ' 3 Script
& e& & я & ।
0s
? e 9p:
9p:
a!! pg
$# я(,6ei6 i") e p ! ' " semicolon(;) &&+ +। яskp e F
3 semicolon(;) e &&+ &8&8" &9 !।
0s
? e p
P:
p
P:
!m" s
n 3 &
e ! 6&" !, !"# ! ! p! & '! . i" m& ।যাহোক F#
p s
n F 3 " u d' a!#37 e a6 + " 6:1 ।
a, (,a-$bt)
t) 0s
?
6! !o & !nt!6t 6h F
!? 3 ! 6A! " & я!#! e
e & 6A " +। p1 !nt!6t ! &! "6
t# &!, # 1#1# я &!, #
& e
&! "6 6h &!। 3 6! 100 !nt!6t 1 " &
& 99 ei & " + &। e & && ei я &k।
" & ! +я 6d" F? +n ,pg e k t +я u6 F " яskp 3। ei 6d" ! + c
"looping"।সঠিক 6l! 8 looping e + 3 6! 6! F
#n Script 'k'
7 k a w 6!"
" 6 &!।
loop statement "n 3, ! '" " + c !।3 ! '" " + " & loop statement '" 6 k
яskp . я 6!" । яskp . я 6!" 6 '" " & +। 3 '" h 1
" & pk & '## +। 3 '" 1 + " & loop (a1Z 6#!&:t я) 1 3 &।3 && + !nt!6 t 1
n " & p1 & ! !nt6t & F !। & 1 "+
e
$ " 6# 6A &।
3 & ! 1 " & looping &n + 3 & ।
a$
яk ($s) f-,a
\- 0s
?
0s
?
object model e # 3$ #&8 6 " ei statement $#
&&h" + । e #+# " 6! 3 object model m n ! &# I!
" & !i e &9 6
! + F।
? (n$f)
n$f) 0s
?
Comment statement d 6! 3 . я
$ " ! ! i . buя 3 mn +o 1 &" "
6 ! । " & ! px я$ " 6 ! " " i? " a ! ! F। 3&
p ' a!#" i!
& '#8# ! я я! F 3 HTML comments e "। & p я! " & . 3
$ "
6।
яskp iE 0s
? u
( JavaScr i pt I f St at ement Tut or i al i n
Bangl a)
яo!#
! яskp .
+
" 3 6!" + & 3 If Statement '" " +।! If Statement u+! +
।
e я " 6& 3 variable 7 e ! + ।
01.<script>
02.<!--
03.var myNum = 7;
04.
05.
06.if(myNum == 7){
07.document.write("Lucky 7!");
08.}
09.//-->
10.</script>
p'!:
Lucky 7!
u6 u+ ! variable !
F myNum e& "
#
F " + c 7। Num e ! &
"!m &I।"6 & 3 If
Statement' e '" 6#!# + c ! a1Z myNum ! 7 + c ! ("myNum == 7") 3 + " & e
" &
& &! &।
я( Lucky 7! )p'" + & ।
! n'!
s
n " F
3 . If Statement ("document.write...") e 1 |; F
"
3 6!" + F।
яskp e
9 iE u
( JavaScr i pt El se I f St at ement Tut or i al
i n Bangl a)
:
6#&&" a8 6! ' F! 3, яskp- e & basic If Statement "7 3। single If Statement e
e a8 '" !d k t basic If Statement +" 1 ।
Else If statement +
basic If Statement e e extension 3 8 6! a !$#
conditional
statement "7 " 6 !।
while loop +
e advance pg 6d" 3 8 ! я && " 6 ! 3! 6! n'!
s
n
" + & । 3o while loop e 8! &&+ e
# я
। e a8 6! & & яskp e while
loop "7 3।
3 condition statement & " + " & 6! !o while loop + " & + " 6 &! ! । "i while
loop &&+ " +o u"।
яskp E
a, u
( JavaScr i pt For Loop Tut or i al i n Bangl a)
:
яskp E
a, e $f%f:
$f%f:
яskp
#6 e $#t# 6#! &9 F।
1 counter variable '#8# t
#6 e k t &&+ я! "7 e + F। ei counter variable d $!!
+ 3 "&
#6 e 6#!&:t
&। i +
counter variable e 8!
।
2 conditional statement dn ! 3
#6 a!&" я (executing)! я" + & + & !। F# u6 e
counter variable (check) ।
3
#6 e increment ' ! p " loop & 6#!&:t 6 counter variable e &:d +।ei &:d 6! .
1 ।
4 #6 e 8 p " loop & 6#!&:t я! ! ; . я(executed) 6!" +।
e
ad# " ! + " 6 " & 1-3 &i ei
i ! . e я!
। e ! + c
#6 standardpg e a!#'7
!।যা designer $d a!#& " 6 ।
#6 e 8 F# s e& &':
+ " k
6o 3।
яskp E
a, e uP'-:
uP'-:
ei u+ ! 8 & 3 & 8!
#6 "7 3 e& counter e value p'" + & 3"k!
! counter 5 e 6F। loop . p1
i ! "! n (i = 0; i < 5; i++)item e & '9 ! 3$
u"। e$#
#6 e $#t# 6#! &9 3 u6 1 + " 3 6 n
! + F।
01.<script type="text/javascript">
02.<!--
03.var linebreak = "<br />";
04.document.write("For loop code is beginning");
05.document.write(linebreak);
06.
07.for(i = 0; i < 5; i++){
08.document.write("Counter i = " + i);
09.document.write(linebreak);
10.}
11.
12.document.write("For loop code is finished!");
13.</script>
p'!:
For loop code is beginning
Counter i = 0
Counter i = 1
Counter i = 2
Counter i = 3
Counter i = 4
For loop code is finished!
counter variable ! (name) i ad# "
$ " 6 " & e
&&+ + F। 9 ! !। i + c
loop counter e default (name) ! । a!! ! variable ! + c j,k,x,ye& z।
ei u+ ! counter p1 0 " ("i = 0;")
+ F। "6 conditional statement
("i < 5;")
+ F। counter 5 + " F
"i
#6 e . я(executed) 6!" + F ।
#6 e . я(executed) 6!" +o 6 ("i++") &:d
F। counter i ! 1 + & "7 + F
।তারপর + 3 5 e F
+ " & 6#!
#6 e . я(executed) 6!" +।ei looping
"
1 3"k! ! counter i 5 e ! + c । ni 5 " 5 + " F
!
#6 e . я(executed) 6!" +o
&n + 3 &।
6! !o Script & pg a"7 "
F! 3 F $ F! ni ! 8! !i 3 ei . 6!
&!।6! m&" #
$ F! " F
!। я! n (Comments)
u"।
3! 6! .
! "! 6! a ! я
я 1 " 6 " & &
+ . 1 F# n
(Comments)an k 3 6! & & + " 3 c। e
'#8# 6! 6&" " s! " +3 & " !,
6! 3 6! . u ! " & "o #& + я . &#I " 6 &। n(Comments) e &a #&8 + c
3! 6! . #
t # n(Comments)e + 3 a!" . # " 6 &!।
ei a8 6! & & #i 8 ! n(Comments) JavaScript e
3
1 single
i! n( comments )
2 multi-
i! n( comments )
SI NGLE LI NE COMMENTS p&W :
:
яskp e single
i! n( comments ) "7 " +
6! . & text e ! # s (slashes) "//"
" + &। я 6!" & p'" + & !। 3! 6! ei # (slashes) "//" &! "! " .! 6 '
text p'" + &
!।3"k! ! 6&"
i ! 3।
1.<script type="text/javascript">
2.<!--
3.// This is a single line JavaScript comment
4.
5.document.write("I have comments in my JavaScript code!");
6.//document.write("You can't see this!");
7.//-->
8.</script>
p'!:
I have comments in my JavaScript code!
яskp af
u
( JavaScr i pt Ar r ay Tut or i al i n Bangl a)
:
a +
e &
3 ! я 8 a !$#
&
я " 6 । a ! pg a!
$# я a F 3
яskp + " n !।
3! 6! яskp e a &&+ &! "! ! 6 n$#
a&'i ! u"।
1 a + c e
& '9 8 ! &
2 array name &&+ 8 a e
# я +। a " a&s! h 6! ic a!#37
b
# я " 6 !। 3!: myArray[2] = "Hello World";
3 array name e 8
# e& " a&s! & 3 ।যেমন: myArray[2]
яskp af
p&W -:
-:
8! &
"7 + " a "7 F#
n। ! JavaScript e &
e& property F 3 a e
+" |;। !"# ! a "7 " 6! special function &&+ " 6 !। ! u+ ! 8 ! + F 3
& 6! 8! a "7 " 6 &!, !
# я " 6 &!, i
# !d " 6 &!।
01.<script type="text/javascript">
02.<!--
03.var myArray = new Array();
04.
05.myArray[0] = "Football";
06.myArray[1] = "Baseball";
07.myArray[2] = "Cricket";
08.
09.document.write(myArray[0] + myArray[1] + myArray[2]);
10.//-->
11.</script>
p'!:
FootballBaseballCricket
k 6! b
# position h
6! ic a!#37
# & " 6 F!।
яskp af
9R[:
8#! 6! a &d
a!# я " (sort) ! " a e sort method e 8 " 6।
01.<script>
02.<!--
03.var myArray2= new Array();
04.
05.
06.myArray2[0] = "Football";
07.myArray2[1] = "Baseball";
08.myArray2[2] = "Cricket";
09.
10.
11.myArray2.sort();
12.
13.
14.document.write(myArray2[0] + myArray2[1] + myArray2[2]);
15.//-->
16.</script>
p'!:
BaseballCricketFootball
3 6! o & buя e яskp ek ! 1 "+
6! Alert " 6 &! !। яskp e
+ c e
.
$ &k 3 pops up e&
" buя ui n + " :; 9! । o & buя Alert я 6a " &8 ।
1 6! 3 !Y" + " ! 3 &&+7(user) website e ! F# $ я !।
1 666 я 3 " confirm " " & OK p " + &।
2 & 666 я 1 e" ! + " & cancel p " + &।
! F# !Y" я! confirm '! pi &&+ + 1 । ei $#t# 6#! я website e 8 mn +।
&&+7$! ! F# submission e& &&+7 &jp p! 3 " 3
k F " 8 a!
website e 3" ic# !।
3 &&+7 OK k " &
# 1 &, 3 &&+7 cancel k " &
# 0 &।
answer e 8 ei
# я । ei answer confirm '! e ! + &
।
p" k ti яskp alert box p'" + & 3 &&+7 я! & + " 3 c। 3 6! i
"$ " !
" & "Bye bye!" p'! & 3 i
1 " ! " & "Thanks for sticking around!" p'! &।
ei a8 p1 & " window.location property &&+ F। ei &9 6&" a8
!
+ F।
яskp pm
e &&+ &" ! 3। яskp pm
e u d' + c &&+7(user) + " "1 g+ 3 " ei
"1$#
e &&+ 3 3
&&+7(user) &k$" a!##" :; + &।
$ ! prompt e &&+ $ F ! personal webpage e ! яj + "। "6 "1
6
6! a&! я + " 3!: "Welcome to My Personal WebPage ferdous alam!" (e ! 6! 3
! &! " p'" + &)
яskp pm
#& я
$ ! e
a ! F &k । " & ' я! e ! ' &।
JavaScript print '! ei я 3! 6! buя ui n i
!# print a6'! । JavaScript
print '! o & 6я e !
n &&+7(user)pn 6h ।
a ! ei '! a!1 ! ।a ! F 3 mu
m n
3 ! ! " k t ei a6'! 1
a ! #&8
+ &।
яskp ,-:-
PR\ $ 1i
k u
( Javascr i pt Redi r ect Tut or i al
i n Bangl a)
:
JAVASCRI PT TI ME DELAY
DELAY
e
! mk 6s" " &' u67।
1.3 ! 6 я
'! 6&" ! ! "+
"Update your bookmarks " e 8 ! e
я !"# !
' !
! 3 " 6 !।
яskp ,, +, ui
?1 u
( Javascr i pt Popup Wi ndow Tut or i al
i n Bangl a)
:
3 e
m string 3 window e n properties 8! ।
window e !! e
$#t# 6#! &9 3 6! e яskp e + 8 6
! " !। 3 + ei # 3$ ei
a8 !i । e ! e &n properties m n
6" &। ! $#t# 6#!
! +
।
1 dependent – 3 6! browser window &n + " & Subwindow &n + &।
Dependent, fullscreen, resizable,e& status &$# ON/OFF properties e u+!। 6! " 'i!
:
Date object #&i $#t# 6#! 3! 6! " p'! " ! a1& e p calculation e k t timestamp &&+
। яskp e &&+7 computer clock a!#37 Date object "7 +।
3! Date object "7 + mu
e an7! a!#37 "! e
#&i $#t# 6#! 3 u &n & u
3 n time zone e a&s!
2.<script type="text/javascript">
3.<!--
5.//-->
6.</script>
7.</h4>
p'!:
I t i s now
яskp 9:
9:
Date object "7 + F e& &
F 3 &" ! " 8! । "1 6o я! 3 p'! &
я! F# '! &&+ &। ! u l +
।
1. getTime() –
n $d! since 1/1/1970 @ 12:00 am
2. getSeconds() – n $d! (0-59)
3. getMinutes() – !
$d! (0-59)
4. getHours() – n $d! (0-23)
5. getDay() – p + ! $d! (0-6). 0=&&, ... , 6= '!&
6. getDate() – ! $d! (0-31)
7. getMonth() – $d! (0-11)
8. getFullYear() – .я
&F (1970-9999)
e! " &9 "1 p'! " 6 &। ! u+ ! getDate, getMonth, e&getFullYear '! &&+
F।
01.<h4>It is now
02.<script type="text/javascript">
03.<!--
09.//-->
10.</script>
11.</h4>
p'!:
I t i s now
яskp ($&R-)
-) 9 x:
x:
e! Date p'! 6& " e! e
p'! & 3 .я
a " 3। HH:MM AM/PM (H
= n , M =!
)।
01.<h4>It is now
02.<script type="text/javascript">
03.<!--
09.}
12.document.write("PM")
13.} else {
14.document.write("AM")
15.}
16.//-->
17.</script>
18.</h4>
p'!:
I t i s now
3 hours or minutes variable 10 + " + " & 7 8 9 i" " & ei ! 'i! & !
a1Z 07, 08,
09 i"। 3 + 1:01 am " & 1:1 am
!।
1.e
text input
!
!।
ER 0
1\- :NON-
NON- EMPTY 06 :
:
e
e
common
i 6
.'! । 6! !Y" + " 6 &! 3 &&+7 eiee
l e 8 .
F
!। eiee
i!6#
!
! e& !d я! ! & яskp .
+
।
01.// If the length of the element's string is 0 then display helper message
02.function notEmpty(elem, helperMsg){
03.if(elem.value.length == 0){
04.alert(helperMsg);
05.elem.focus(); // set the focus to this input
06.return false;
07.}
08.return true;
09.}
notEmpty function 3 eiee
input e 3
6A & ! F# F !। elem +
HTML text input ei '! 6A & । яskp strings e built in property F। " 8 e +
length property । 3 string e length return । e
&a . elem.value 3 input e " string
। . length 3#k +। ' 9 a elem.value.length ।
elem.value.length 3 'i! ! + &
! + " & " &
6i। a!1 helperMsg e + 3
&&+7 ! e alert я p '" + । 1 &&+7 #
+ F ei я " ! ' । e
1 + &
6o 3।
u+!:
01.<script type='text/javascript'>
02.function notEmpty(elem, helperMsg){
03.if(elem.value.length == 0){
04.alert(helperMsg);
05.elem.focus();
06.return false;
07.}
08.return true;
09.}
10.</script>
11.<form>
12.Required Field: <input type='text' id='req1'/>
13.<input type='button'
14.onclick="notEmpty(document.getElementById('req1'), 'Please Enter a
Value')"
15.value='Check Field' />
16.</form>
p'!:
Required Field:
ER 0
1\- - 9$ i-,a 9[%f - & 06 яn:
яn:
3 u k.
.,! !m, zip . i" i!6#
k
" & 6! . 8 !Y" " + & 3 i!6#
k
+ & । e& d" u6 + c 3 input e string
# + & 3 regular expression + c /^[0-
9]+$/ e& " match & 3 string + & " an"6 k e character e +।
01.// If the element's string matches the regular expression it is all
numbers
02.function isNumeric(elem, helperMsg){
03.var numericExpression = /^[0-9]+$/;
04.if(elem.value.match(numericExpression)){
05.return true;
06.}else{
07.alert(helperMsg);
08.elem.focus();
09.return false;
10.}
11.}
u6 . " p " string +
e function 3 ! match । ei function &&+ " 6 ! 3
string e 1 match F !। e & &&+ " 6 3!:
elem.value.match(e ! expression)
3 " i 3 i!6#
string & F
!, k t я! regular expression "7
F 3 numericExpression + & я ।
regular expression e +" match function &&+ F। 3 e
numeric + 1
" &match function " &
6&। isNumeric function o " &
6&। 3 i!6#
string
&d & a! characters + " & expression &1 + &।
helperMsg p'" + & e& 1 &
6&।
u+!:
01.<script type='text/javascript'>
02.function isNumeric(elem, helperMsg){
03.var numericExpression = /^[0-9]+$/;
04.if(elem.value.match(numericExpression)){
05.return true;
06.}else{
07.alert(helperMsg);
08.elem.focus();
09.return false;
10.}
11.}
12.</script>
13.<form>
14.Numbers Only: <input type='text' id='numbers'/>
15.<input type='button'
16.onclick="isNumeric(document.getElementById('numbers'), 'Numbers Only
Please')"
17.value='Check Field' />
18.</form>
p'!:
Numbers Only:
ER 0
1\- - 9
i-,a $zR - & 06
яn:
яn:
ei isAlphabet function isNumeric function e " " & &"k '#8# t regular expression 6&" !
k t। " match function &&+ F । e ! 6& " &d &। 3
" i string '#8# &d 8! &, " & lowercase e& uppercase u k t expression ! ;
&।
01.// If the element's string matches the regular expression it is all
letters
02.function isAlphabet(elem, helperMsg){
03.var alphaExp = /^[a-zA-Z]+$/;
04.if(elem.value.match(alphaExp)){
05.return true;
06.}else{
07.alert(helperMsg);
08.elem.focus();
09.return false;
10.}
11.}
u+!:
01.<script type='text/javascript'>
02.function isAlphabet(elem, helperMsg){
03.var alphaExp = /^[a-zA-Z]+$/;
04.if(elem.value.match(alphaExp)){
05.return true;
06.}else{
07.alert(helperMsg);
08.elem.focus();
09.return false;
10.}
11.}
12.</script>
13.<form>
14.Letters Only: <input type='text' id='letters'/>
15.<input type='button'
16.onclick="isAlphabet(document.getElementById('letters'), 'Letters Only
Please')"
17.value='Check Field' />
18.</form>
p'!:
Letters Only:
ER 0
1\- - 9
$zR e$[ 9[%f 06 яn:
яn:
isAlphabet e& isNumeric function u et e function e #6n" F 3 d
i!6#
&d o u " 6। 3!: isAlphanumeric
01.// If the element's string matches the regular expression it is numbers
and letters
02.function isAlphanumeric(elem, helperMsg){
03.var alphaExp = /^[0-9a-zA-Z]+$/;
04.if(elem.value.match(alphaExp)){
05.return true;
06.}else{
07.alert(helperMsg);
08.elem.focus();
09.return false;
10.}
11.}
ER 0
1\- - CHARACTER e pPxRf $ LENGTH e $n-
mn:
$n-
mn:
Character !m &8! 98 &&+7 + я field e p &' " 6 &
ap .
p" 8 3। 3!
6! я !! 3 zip . 5 +o u" k t 2 +o u" !। ! lengthRestriction function
"7 F ! # 8
k
.
i!6#
я! minimum e& maximum Character e
!8! F।
01.function lengthRestriction(elem, min, max){
02.var uInput = elem.value;
03.if(uInput.length >= min && uInput.length <= max){
04.return true;
05.}else{
06.alert("Please enter between " +min+ " and " +max+ " characters");
07.elem.focus();
08.return false;
09.}
10.}
u+!:
01.<script type='text/javascript'>
02.function lengthRestriction(elem, min, max){
03.var uInput = elem.value;
04.if(uInput.length >= min && uInput.length <= max){
05.return true;
06.}else{
07.alert("Please enter between " +min+ " and " +max+ " characters");
08.elem.focus();
09.return false;
10.}
11.}
12.</script>
13.<form>
14.Username(6-8 characters): <input type='text' id='restrict'/>
15.<input type='button'
16.onclick="lengthRestriction(document.getElementById('restrict'), 6, 8)"
17.value='Check Field' />
18.</form>
p'!:
Username(6-8 characters):
ER 0
1\- - SELECTION p&W :
:
e ! madeSelection function &&+ + F। &&+7 eiee
select input + " 3 ! &9 select
" 6 &!। 6! 8! trick + & &&+7 я! p1 a6'! +37 prompt + & " 6 !। p1
a6'! + & select input- e F# " 6 ! 3!: "Please Choose" ।
01.function madeSelection(elem, helperMsg){
02.if(elem.value == "Please Choose"){
03.alert(helperMsg);
04.elem.focus();
05.return false;
06.}else{
07.return true;
08.}
09.}
u+!:
01.<script type='text/javascript'>
02.function madeSelection(elem, helperMsg){
03.if(elem.value == "Please Choose"){
04.alert(helperMsg);
05.elem.focus();
06.return false;
07.}else{
08.return true;
09.}
10.}
11.</script>
12.<form>
13.Selection: <select id='selection'>
14.<option>Please Choose</option>
15.<option>CA</option>
16.<option>WI</option>
17.<option>XX</option>
18.</select>
19.<input type='button'
20.onclick="madeSelection(document.getElementById('selection'), 'Please
Choose Something')"
21.value='Check Field' />
22.</form>
p'!:
Selection:
ER 0
1\- – i
i
0
1\-:
0
1\-:
e! 6! & 3, &&+7 i i
&8 ! " & 6! " 6 &! ।
a&'i i i
an"6 k @ sign e& dot (.) 1 & 3 ! @ sign i i
e p1 Character + & ! e& ' 9 dot
(.) @ sign e 6 a&'i e Character e + &।
Valid u+!:
• bobby.jo@filltank.net
Invalid u+!:
u+!:
01.<script type='text/javascript'>
02.function emailValidator(elem, helperMsg){
03.var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
04.if(elem.value.match(emailExp)){
05.return true;
06.}else{
07.alert(helperMsg);
08.elem.focus();
09.return false;
10.}
11.}
12.</script>
13.<form>
14.Email: <input type='text' id='emailer'/>
15.<input type='button'
16.onclick="emailValidator1(document.getElementById('emailer'), 'Not a Valid
Email')"
17.value='Check Field' />
18.</form>
p'!:
Email:
ER 0
1\- – 9$ e ah
&R:
p " e яskp event F 3 ! onSubmit । e
я 3! e &
&
! k +। 3 ei event
0 & 1 return " & &
+ & !। 3 e
1 & " &
return " & &
+ &। &
e
k t e ! Validator '! &&h" + F।
p'!:
First Name:
Address:
Zip Code:
State:
Username(6-8 characters):
Email:
Check Form
:яo!#
яo!#
e
6! F 6#"! ! + " 6 " & " p " яskp s +
"6 '! 3 6! 'k я a 6k
1 । e ! + c яskp-e s i
" e $#c property e& function(3 method o &
+) &'; object ।
03.
04.//This is how you would access a property
06.
09.</script>
Pseudoяskp .:
<script type="text/javascript">
var myString = "Hello Thur!";
String Function?
+,-String9m
R a
-ia 0,
&String Function a
- u,W। 0r-: +,-String Functione
nf
String0,
- e$[ a
-g
%
?1 $k
- 0r%
-characterg
+,- 9$'
i-।
e grt,a-R $m '
~ ei E[\-g
&String0 ,$&R-
- &
$ & -&a-String-R
r +,- я %
& ,
-।
String Functionse$[Properties:
ei anf
0P%
- '
i
$ +,-String0 ,6
-, Vz-, p&s,-, a1R e$[ 96R
&
,
-। eiadvanced$m +,-
dynamico
$ 0,я p&W 0k
t -&a- e яV
& d u
n6-
0P
$ ।
яskpString Length:
яskp .:
<script type="text/javascript">
var myString = "123456";
// Same thing, but using the property inside the write function
document.write("<br />The string is this long: " + myString.length);
</script>
pP\R-:
<script type="text/javascript">
var myString = "123456";
document.write("The string is this long: " + myString.length);
</script>
pP\R-:
01.<script>
02.var myString = "123456";
03.
04.var length = myString.length;
05.
06.document.write("The string is this long: " + length);
07.
08.// Same thing, but using the property inside the write function
09.document.write("<br />The string is this long: " + myString.length);
10.
11.</script>
p'!:
The string is this long: 6
The string is this long: 6The string is this long: 6
The string is this long: 6
s &n
# " &k k" 3 a ! pg
$# я 1! । яskpo " ।3 6! a !
m s
3!: "Bobby Susan Tracy Jack Phil Yannis" e& p " !
& я " 6 !। 6!
space character " " ! ' " 6 !। split function !"# !
# "7 & 3 p"& s
k ।
p'!:
The first element is 1234
The second element is 6789The first element is 1234
The second element is 6789
u6 u+ ! 5 delimiter + & 6Fn F। " & e
!। ! delimiter String + "
&"a" +। 6&" character $#
n a' d 6:1 +।
p'!:
Element 0 = zero
Element 1 = one
Element 2 = two
Element 3 = three
Element 4 = four
Element 0 = zero
Element 1 = one
Element 2 = two
Element 3 = three
Element 4 = four
6! 3 a!
i! 1 e& 3i iuя ! e ap"'" 'b an# k + F 3 6! ! я!$! i iuя ! "7
1 &" 1k " & 6! search function e 8 & # я & iuя ! e ap"'" 'b$#
&
" 6 !।
p'!:
There was a match at position 45There was a match at position 45
k #!, regular expression F
'#8# e
! "Alex" ।
search function ei ! &&+
F 3 string1 e e
u6s" F !। e
' ! 1 match F
match e 6я'! (45)
6 F।
p'!:
There was a match at position 6There was a match at position 6
k #! regular expression e # ! F: Alex e& John ।
search function ei ! #
#я " &&+ F e& F string1 e e$#
u6s" F !।
p'!:
The first string found a match at 39
No match was found in the second string
The third string found a match at 39
No match was found in the fourth stringThe first string found a match at 39
No match was found in the second string
The third string found a match at 39
No match was found in the fourth string
яskp sT[
p9 ( JavaScr i pt St r i ng Repl ace)
:яo!#
яo!#
яskp s a& яk e e! k" F 3 8 6! s e " 3 ! 'b p " 6 !। p ' !
+ 8 6! ei
ee
e 8 6! &&+7 ! g+ " 6 !।
s p '!:
'!
s p '! e #i 8 ! 3#k F:
1.SearchFor: ! 'b p + " 3 c। e
+ " 6 s & $#
ek p'!।
p9 E[\-:
E[\-:sT[
p9
e! s & e& &&+7 ! d e
p &। p1 3#k + c F e& d"7 + c
p " 3c।
01.<script>
02.var visitorName = "Chuck";
03.var myOldString = "Hello username! I hope you enjoy your stay username.";
04.var myNewString = myOldString.replace("username", visitorName);
05.
06.document.write("Old string = " + myOldString);
07.document.write("<br />New string = " + myNewString);
08.
09.</script>
p'!:
Old string = Hello username! I hope you enjoy your stay username.
New string = Hello Chuck! I hope you enjoy your stay username.Old
string = Hello username! I hope you enjoy your stay username.
New string = Hello Chuck! I hope you enjoy your stay username.
u6 3 c '#8# t p1 iuя ! 6&" " + F। e
+ c SearchFor 3#k 7&d"। $#
ek p'! &&+
8 ei # " 6।
p9 E[\-:
E[\-:0g
ek
p\-
s e 6& " $#
ek p'! &&+ &। e ! 61 + c '#8#
' ! 6& " s' &&+ &।
01.<script>
02.var visitorName = "Chuck";
03.var myOldString = "Hello username! I hope you enjoy your stay username.";
04.var myNewString = myOldString.replace(/username/, visitorName);
05.
06.document.write("Old string = " + myOldString);
07.document.write("<br />New string = " + myNewString);
08.
09.</script>
p'!:
Old string = Hello username! I hope you enjoy your stay username.
New string = Hello Chuck! I hope you enjoy your stay username.Old
string = Hello username! I hope you enjoy your stay username.
New string = Hello Chuck! I hope you enjoy your stay username.
n "6o 3 c & iuя ! 6&" ! +!। $#
ek p'! e g&
p6 8 ei # 3।
p9 E[\-:
E[\-:0g$
0g
ek
p\-
$#
ek p'! e ' 9 g i!6#
g&
ek p'! "7 " 6।
01.<script>
02.var visitorName = "Chuck";
03.var myOldString = "Hello username! I hope you enjoy your stay username.";
04.var myNewString = myOldString.replace(/username/g, visitorName);
05.
06.document.write("Old string = " + myOldString);
07.document.write("<br />New string = " + myNewString);
08.
09.</script>
p'!:
Old string = Hello username! I hope you enjoy your stay username.
New string = Hello Chuck! I hope you enjoy your stay Chuck.Old string
= Hello username! I hope you enjoy your stay username.
New string = Hello Chuck! I hope you enjoy your stay Chuck.
3 + ' 9
+
। ! " + & 3 3 e 'b p " i k t s & 8! $#
ek p'! &&+ u"।3 & p " i k t g&
$#
ek p'! &&+ u"।
яskp sT[ i-
1kaE E[\- u
( JavaScr i pt i ndexOf Funct i on)
:яo!#
яo!#
s '! indexOf e 8 6! 8! p я ! #i 8 ! 3#k '! 8 6 &!। p1 + c
e& 6 + c a
।
sT[ i-
1kaE E[\-:
E[\-:
i! .ka ' ! # 8 ! 3#k F। 3 d"7 + c c।
01.<script>
02.var aURL = "http://www.tizag.com/www.html";
03.var aPosition = aURL.indexOf("www");
04.var secondPos = aURL.indexOf("www", aPosition + 1);
05.
06.document.write("The position of www = " + aPosition);
07.document.write("<br />The position of the second www = " + secondPos);
08.
09.</script>
p'!:
яskp 0Ve
?$i+i1(
0Ve
?$i+i1( JavaScr i pt get El ement ByI d Tut or i al i n
Bangl a)
:яo!#
яo!#
яskp: .k n $
e
n&ii. (document.getElementById)
яskp .k n.$
e
n&ii.
01.<script>
02.function notEmpty(){
04.if(myTextField.value != "")
06.else
08.}
09.</script>
p'!:
document.getElementById i
k
eiee
e
n e n
! । ei
n myTextField ! &
я " 6।
$
e
n&ii. &9 3 ! :
3! 6! getElementById function &&+ &! "! 6! F# &9 n n !Y" +o p я!। 6!
a&'i ! p я! 3 $
e
n&ii. + c .k n a& яk e 6d" & '!।6! ei $
e
n&ii. '!
&&+ " i
6! a&'i eiee
e
n e i. e&u
&&+ " + &।
:яo!#
яo!#
e
&m 3 & eiee
!
n 6&" ! " 6 &! i! eiee
e 8
k
6&" !
" 6।
i! eiee
(innerHTML) e 8
k
6&" !:
!
p " eiee
e
n e i! eiee
p6 F 3 eiee
. e&
k
u ! ' 3 o 6! e&
kя
$ 8 6o 3।e
n i! eiee
p6 6&" ! 9d7 o & 6я "7 3।
i! eiee
p6 +я & &&+ " i
F# ps" p я!। p1 e
n e i. " + & "6
" getElementById function e 8 6
! " + &।
1.<script>
2.function changeText(){
4.}
5.</script>
p'!
Welcome to the site dude
3 + я!
& eiee
e
n e
k
6&" ! 3।n e!o я!! & &&+7
k
6 k eiee
k
6&" ! " 6 &। ! e
! +
।
iuя i-,a
u, t
t
0k
,$&R
,$&R-:
01.<script>
02.function changeText2(){
04.document.getElementById('boldStuff2').innerHTML = userInput;
05.}
06.</script>
01.<script>
02.function changeText3(){
05.document.getElementById('para').innerHTML = newHTML;
06.}
07.</script>
p'!
Welcome to the site dude