Hyperlink empty

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
cmagnan
Posts: 23
Joined: Fri Jan 26, 2018

20 Feb 2018

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

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

21 Feb 2018

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.
Cheers

cmagnan
Posts: 23
Joined: Fri Jan 26, 2018

21 Feb 2018

Thank you very much Nikita,
I was exactly what I need

cmagnan
Posts: 23
Joined: Fri Jan 26, 2018

16 Mar 2018

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

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

16 Mar 2018

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!");
    }
});
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests