what's the meaning of this code

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
junjustkim
Forum Commoner
Posts: 44
Joined: Thu May 22, 2008 8:48 pm

what's the meaning of this code

Post by junjustkim »

Hi to all, I have found some script and I don't know the meaning especially with the especiall chatacter, I highlighted with color blue. This is my second week for learning web desing using php. I already look at the javascript but I didn't found it. Actually I found this code insside filename.js so my understanding is about with javascript. Please take a look at the code and give me an idea.

Thanks in advance

Code: Select all

 
// validators ------------------------------------------------------------------
    
function isEmpty (s) {
    var p = /\S+/;
    return !p.test(s);
}
 
function isEmail(string) {
    if (string.search[color=#0000BF](/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1[/color])
        return true;
    else
        return false;
}
 
function isAlphaNum(string) {
    if (string.search(/^[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}
 
function isNum(string) {
    if (string.search(/^[0-9]+$/) != -1)
        return false;
    else
        return true;
}
 
function isExecutable (s) {
    var p = [color=#0000BF]/\.(bat|com|dll|exe|vbs)$/i;[/color]
    return p.test(s);
}
 
function isImage (s) {
    var p = /\.(gif|jpg)$/i;
    return p.test(s);
}
 
function isUrl (s) {
    var p = /^(http|https|ftp):\/\/\S+\.[^\.\s]{2,4}(\/\S*)?$/i;
    return p.test(s);
}
 
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: what's the meaning of this code

Post by onion2k »

It's some validation functions to test if strings match against some regular expressions.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: what's the meaning of this code

Post by VladSun »

It's called "regular expression" - google it :)
Also it's not PHP, but a JavaScript code :)
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: what's the meaning of this code

Post by pickle »

Moving thread to Client Side.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
junjustkim
Forum Commoner
Posts: 44
Joined: Thu May 22, 2008 8:48 pm

Re: what's the meaning of this code

Post by junjustkim »

Thank you very much for all your replied, But I want to know the meaning of each character so that later I could used this if needed. Where tutorial I can find this code.

Thanks
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: what's the meaning of this code

Post by onion2k »

It's called "regular expression" - google it
junjustkim
Forum Commoner
Posts: 44
Joined: Thu May 22, 2008 8:48 pm

Re: what's the meaning of this code

Post by junjustkim »

Thank you so much, Now I know.

Until next post.
Post Reply