M
MJ
For some reason the following script does not work in Netscape/Mozilla, but
works fine in IE and Opera. It is supposed to check the syntax, make sure
there is a valid TLD (yes, those are all of the current TLDs), and allow for
addresses with or without trailing slashes or page addresses.
Anybody have any ideas on how to get this to work in Netscape? I suspect it
has something to do with the regular expression, but I can't get it to work.
Any help would be GREALY appreciated!
// Validate URL
re3 =
/^(http|https):\/\/\S+\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at
|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc
|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|
ec|edu|ee|eg|er|es|et|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov
|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|
is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|l
v|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|
mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|
pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|
sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|u
g|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)([/]\S+|)$/i;
function validateURL(textfield){
if (textfield.value == ""){
return true;
} else {
if (textfield.value.substring(0,7) != "http://" &&
textfield.value.substring(0,8) != "https://") {
textfield.value = "http://" + textfield.value;
}
if (!re3.test(textfield.value)){
alert("Invalid web site address");
textfield.focus();
}
return false;
}
}
It is being called by a simple:
<input name="Website" type="text" onBlur="validateURL(this)">
works fine in IE and Opera. It is supposed to check the syntax, make sure
there is a valid TLD (yes, those are all of the current TLDs), and allow for
addresses with or without trailing slashes or page addresses.
Anybody have any ideas on how to get this to work in Netscape? I suspect it
has something to do with the regular expression, but I can't get it to work.
Any help would be GREALY appreciated!
// Validate URL
re3 =
/^(http|https):\/\/\S+\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at
|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc
|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|
ec|edu|ee|eg|er|es|et|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov
|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|
is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|l
v|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|
mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|
pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|
sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|u
g|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)([/]\S+|)$/i;
function validateURL(textfield){
if (textfield.value == ""){
return true;
} else {
if (textfield.value.substring(0,7) != "http://" &&
textfield.value.substring(0,8) != "https://") {
textfield.value = "http://" + textfield.value;
}
if (!re3.test(textfield.value)){
alert("Invalid web site address");
textfield.focus();
}
return false;
}
}
It is being called by a simple:
<input name="Website" type="text" onBlur="validateURL(this)">