Welcome to my page… In “We Are Knowledge”.
Hai..This Page is continue from “string”..
If ago about “manage text with javascript”. And this time I
want giving you about “manage Object String”..
Yeah that’s right.. This page still about “string”..
Ok direct.. Let’s read it…
B. Manage Object
String
Ago we reading string about formatting text, and I hope you
understand with it. And Now next method other string for manage and
manipulation object string and many example.
Method
|
Define
|
charAt(x)
|
To result character at position x in a string
|
charCodeAt(x)
|
To result Unicode value from character at position x in a string
|
Concat(text1, text2)
|
For to fuse more string
|
formCharCode(c1,..)
|
To resule value string with queue unicode value
|
indexOf(substr,[start])
|
Looking for and if to be founded want to result number “index number”
from character in string. “start” is agument opsional , and start position for
looking for
|
Match(regexp)
|
To result array value information, if nothing to be found want to result
“null”
|
Replace(regexp, replacetext)
|
Looking for and change string searched founde regular pola expression
|
Search(regexp)
|
Testing regular pola expression with string of same. If not same to
result “-1”
|
Slice(start,[end])
|
To result substring from a string founde “start” and “end”
argument
|
Split(delimeter,[limit])
|
For cutting string founde ristiction, and to result form “array”
|
Substr(start, [length])
|
To result character and substring from a string from “start” until
long “length” searched
|
Example 1 :
1. validation email, Now
we want correct email valid or not valid. Method That “email” string with
character @ or point(.)
You can copy this code And Paste In your software
<html>
<head>We Are
Knowledge<br><br>
<title>Tutorial
Javascript - String</title>
<form
name="test" onSubmit="checkemail(this.test2.value);return
false">
<input
type="text" size=20 name="test2"> <input
type="submit" value="SEND">
</form>
<script
type="text/javascript">
function
checkemail(email)
{
if
(email.indexOf("@") !=-1 && email.indexOf(".")
!=-1)
alert("GOOD
JOB")
else
alert("BAD
JOB")
}
</script>
</body>
</html>
And Result :
If you Input character “@” and “.” Alert to appear “GOOD JOB”
And If Not.. Alert to appear “BAD JOB”
Example 2 :
Now I want made for counting “word“ not “character”… If you
will made count of character please leaving comment, I want made for you.
You can copy this code And Paste In your software
<html>
<head>We Are
Knowledge<br><br>
<title>Tutorial
Javascript - String</title>
<form
name="x">
<textarea
rows="14" name="y" cols="40">
</textarea><br>
<input
type="button" value="count" onClick="g()">
<input
type="text" name="z" size="22">
</form>
<script
type="text/javascript">
function g()
{
var
a=document.x.y.value
b=a.split("
")
document.x.z.value=b.length
}
</script>
</body>
</html>
Ok…. Just it…
If you having
question please leaving comment… And please wait.. I want try for answer your
question..
Thanks for you..
And Thanks for reader
No comments:
Post a Comment