Hi, I am desperate to get this fixed. I have a web registration form that the user enter’s in their companies URL . It all works fine but the user are putting alot of garbage in the field. For example some people put “None” or “N/a”. They may also put in malformed URL like “sillyuser.com” that is not prepended with Http://www.
Is there a way to force the user to put in the web site in a certain format? If so how?
And is there a way i can run an agent over the previously entered URL’s to clean them up to check if they are prepended with Http://www…
thanks a bunch, this is being used as a referral system and the users wont get a referral if they dont enter in their companies URL correctly
Subject: Validate URL and Fix previous entries through view
Hi,
If its a web application, then you can force the user to valid value into a particular field with the help of javascript validation. But you need to decide, what are the formats you are going to allow to the user as a website. e.g. http://www. or https://www. or something else. If the starting characters match these values then you can pass the validation, otherwise the validation fails.
The 2nd part of your query is to correc the existing records. If you just want to prepend http://www. where it is not there, thats possible. But it is not possible decide, what website name is to be there if -None- is provided. So, while fixing also you can have certain defined formats and you can prepend the same.
Subject: RE: Validate URL and Fix previous entries through view
Thanks for your quick response, I guess the main thing to start would be what javascript would force the user to start their URL with http://www. or https://www. ?
I would like the javascript to give an error once they start typing something irregular and not in the above format.
I dont want anything placed in the field but the following formats:
function isURL(urlStr){if (urlStr.indexOf(" “)!=-1){alert(“Spaces are not allowed in a URL”);return false;}if(urlStr==”“||urlStr==null){return false;}urlStr=urlStr.toLowerCase();var specialChars=”\(\)><@,;:\\\"\.\[\]“;var validChars=”[^\s" + specialChars + “]”;var atom=validChars + ‘+’;var urlPat=/^http://(\w*).([-+a-z0-9]).(\w)/;var matchArray=urlStr.match(urlPat);if (matchArray==null){alert(“The URL seems incorrect \ncheck it begins with http://\n and it has 2 .'s”);return false;}var user=matchArray[2];var domain=matchArray[3];for (i=0; i<user.length; i++) {if (user.charCodeAt(i)>127) {alert(“This domain contains invalid characters.”);return false;}}for (i=0; i<domain.length; i++) {if (domain.charCodeAt(i)>127) {alert(“This domain name contains invalid characters.”);return false;}}var atomPat=new RegExp(“^” + atom + “$”);var domArr=domain.split(“.”);var len=domArr.length;for (i=0;i<len;i++) {if (domArr[i].search(atomPat)==-1) {alert(“The domain name does not seem to be valid.”);return false;}}if (domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {alert("The address must end in a well-known domain or two letter " + “country.”);return false;}return true;}