Jump to content

Little hlp plz


Dathremar

Recommended Posts

Hello, I really can't figure out this (cuz I am really not good with javascript) :

function valid_web(web)

{

var filter  = /([a-zA-Z0-9_\.\-])+(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

uslov = ((web.substr(0,4) == "www.") || (web.substr(0,7) == "http://"));

return (uslov && filter.test(web));

}

This is function for validatin if it is a web/link ok i get that, but when i input a name like this one : http://path/to/file/Upatstvo voip mk v1 5.doc - it returns false. If I just delete the last blank spot between the 1 and 5 it returns true. Because this doesn't make any sense to me, could be some1 kind enough and knows java script to explain to me whats happening in the function. Or at least explain the filter variable (thats what i dont understand meaning what all those signs mean, which of them are the filter and which are the concatenation or something marks).

Thx

Link to comment
Share on other sites

Yeah that's true. But the same variable here it is used for the link to the file and for the file name so if i change that then the link will not work. Imo it is stupid to upload files without changing their name or at least adopt them for further usage, but i am not the creator of this program :( So I can't change that.

About the blank spaces. Strange thing is that only the last blank space is making a problem. If i remove only the last one then the name is valid.

Thats why I wanted some1 to explain the filter to me in more details.

 

ie. This part a-zA-Z0-9 i know it means it can include a-z and A-Z letters number 0-9,but i dont understand _\.\-])+(( and \-])+\.)+( in between this info.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.