Page 1 of 1
Hyperlink empty
Posted: 20 Feb 2018
by cmagnan
Hi,
Is it possible to know if a hyperlink is empty. I know how to do it for text field but not for a hyperlink
Thanks
Re: Hyperlink empty
Posted: 21 Feb 2018
by Nikita Kurguzov
Dear Catherine,
It should be possible, but what do you mean by empty? No value or not valid URL? By default, you can check Hyperlink on New Form or Edit Form like this:
Code: Select all
if(fd.field('URL').value()[0] == 'http://'){
alert('Empty!');
}
For Display form:
Code: Select all
if(fd.field('URL').value()[0] == " "){
alert('Empty!');
}
But this code will only check if user added some changes or not, if user simply deletes
http:// part, it wouldn't work. Let me know your exact needs and we can write better code for you.
Re: Hyperlink empty
Posted: 21 Feb 2018
by cmagnan
Thank you very much Nikita,
I was exactly what I need
Re: Hyperlink empty
Posted: 16 Mar 2018
by cmagnan
Hi,
I am trying to implement the code in the edit form using the code from this post
viewtopic.php?f=1&t=686&sid=cc6893c598c ... 5&start=10
When only http is indicated the alert is displaying, but the border not coming in red.
Do you have an idea?
Thanks
Catherine
Re: Hyperlink empty
Posted: 16 Mar 2018
by Nikita Kurguzov
Dear Catherine,
The code for single line should work just fine, although it highlights description input too. You can also try this to highlight only first line:
Code: Select all
var error = false;
function checkFields(){
error = false;
if(fd.field('URL').value()[0] == 'http://'){
setRedURL('URL');
}
}
function setRedURL(fieldname){
$('.fd_field[fd_name='+fieldname+'] input:first').css(
{'border-color': 'rgba(245,25,10,0.6)',
'box-shadow': '0px 0px 10px 0px rgba(245,5,90,0.8)'})
.change(function(){
self = $(this);
if (self.text){
self.css(
{'border-color': '',
'box-shadow': ''})
}
});
error = true;
}
fd.onsubmit(function(){
checkFields();
if(!error){
return true;
}
else{
alert("Please, fill in the mandatory fields!");
}
});