Jump to content

Recommended Posts

To show the URL in a Caspio page and to be able to open it, it has to start with HTTP or HTTPS so you can use the code below:

 

<script>
function v_url(){

var myRegExp =/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/i;

var urlToValidate = document.getElementById('InsertRecordURL').value;
if (!myRegExp.test(urlToValidate)){

alert("Not a valid URL.");
return false; 
}
}

document.getElementById('Submit').onmouseover = v_url;

</script>

Make sure to replace InsertRecordURL with the actual URL field ID which is in this format InsertRecord+FieldName

 

Put the code in the Footer

Share this post


Link to post
Share on other sites

Hey thanks , i just used your script.

 

I have it submit then  innerHTML this tag  in HTMLBLOCK 2  

 <p id="urlerror" > </p>

http://www.tripatwork.com/register-a-travel-agency-1

 

The issue is after the error shows up in the <p> tag it disappears.

Any help would be appreciated.

Thanks !

 

[Altered Script slightly]

<script>
function v_url(){
var myRegExp =/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/i;

var urlToValidate = document.getElementById('InsertRecordTagWebURL').value;
if (!myRegExp.test(urlToValidate)){

//alert("Incorrect Web Site URL entered !");

var oldHTML = document.getElementById("urlerror").innerHTML="Website Address is Invalid ! ";
 var newHTML = "<span style='color:#ff0000;font-family:Arial; color:Red; font-size: 16px'>" + oldHTML + "</span>";
 document.getElementById('urlerror').innerHTML = newHTML;

//return false; 

}
}

document.getElementById('Submit').onmouseclick = v_url;

</script>

Share this post


Link to post
Share on other sites

Sorry for the late reply.

Its not, I was trying to put it in a Div or P tag,

Would be awesome to have it show up in the text box.

Tahnks ! 

 

something like this

this script validates a phone number on the fly in the text box

 

------------------------------------------------------------------------------------------------

<SCRIPT LANGUAGE="JavaScript">
function f_a(v_id)
{
return document.getElementById(v_id);
}
f_a('InsertRecordTacyPrimaryBizTel').maxLength = 14;
f_a('InsertRecordTacyPrimaryBizTel').onkeyup = function(v_e)
{
v_e = v_e || window.event;
if (v_e.keyCode >= 65 && v_e.keyCode <= 90){
this.value = this.value.substr(0, this.value.length - 1);
return false;
}else if (v_e.keyCode >= 37 && v_e.keyCode <= 40){
return true;
}
var v_value =(this.value.replace(/[^\d]/g, ''));
if (v_value.length==7) {
this.value = (v_value.substring(0,3) + "-" + v_value.substring(3,7));}
else if(v_value.length==10){
this.value = ("(" + v_value.substring(0,3) + ") " + v_value.substring(3,6) + "-" + v_value.substring(6,10));
};
}
</SCRIPT>

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...