Dathremar Posted July 2, 2008 Share Posted July 2, 2008 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 Quote Link to comment Share on other sites More sharing options...
cleary1981 Posted July 2, 2008 Share Posted July 2, 2008 I'm not an expert but it looks to me that your first line is a filter that only allows certain characters to be used. Spaces are not included in web links. Could you change the path to use underscores instead of spaces? That would solve your problem. ie; http://path/to/file/Upatstvo_voip_mk_v1_5.doc Quote Link to comment Share on other sites More sharing options...
Dathremar Posted July 2, 2008 Author Share Posted July 2, 2008 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. Quote Link to comment Share on other sites More sharing options...
Zhadus Posted July 2, 2008 Share Posted July 2, 2008 Instead of changing the file to have underscores, write the link as the computer sees it with %20 instead of a space. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.