Requiring a person submitting a URL to use one that begins https://

  • Profile Image
    rtolmach
    Asked on December 23, 2017 at 03:46 PM

    Hi Jotform


    Creating this form

    https://www.jotform.com/build/73505129184153

    You can see it here:  https://form.jotform.com/73505129184153


    We have a field called:

    URL of photo of book. Grab from google, amazon, or any book site.


    I want to put a validator on it so that the person has to use a URL that begins with these characters

    https://

    For instance, it might be:

    https://mysite.com/book123.jpg


    I do not want to display https://  in the field and have them add the rest, since they are likely to copy and paste the entire URL from a site, and then we would end up with double https://


    I would also like to show an error message if they submit a URL that does not begin with that.


    Thanks!
    Robert



  • Profile Image
    Adrian
    Answered on December 23, 2017 at 05:07 PM

    Hi Robert,

    I have cloned your form and I think I have achieved what you are asking with the help of a textfield.

    Here is the URL to my cloned form: https://form.jotform.com/73566665163970

    Please check it and see if it is what you are asking for.

     

    Here is what I did:

    After cloning your form, I added a Short Text Entry element to the form. It's ID is #input_52.
    First thing I did is I made it REQUIRED and put a placeholder "MUST BEGIN WITH HTTPS://".

    After that I injected some Custom CSS to make it look like a validation message. Here is the CSS:

    #label_52 { display: none !important; } #input_52 { border: 0 !important; background: transparent !important; box-shadow: none !important; } #input_52::-webkit-input-placeholder { color: red; } #input_52::-moz-placeholder { color: red; } #input_52:-ms-input-placeholder { color: red; } #input_52:-moz-placeholder { color: red; }

    Then I added three IF conditionals:

    1.1514066722r1.png

    2.1514066748r2.png

    3.1514066787r3.png

     

    You can clone my form, or follow the steps that I used.
    Here is a guide on How to Clone an Existing Form from a URL

    Please let me know if you need further assistance.

     

  • Profile Image
    rtolmach
    Answered on December 23, 2017 at 09:43 PM
    Awesome! Thank you for the fantastic support.
    Best
    Robert

    ...
  • Profile Image
    rtolmach
    Answered on December 31, 2017 at 05:32 PM

    Hi Adrian

    Looking at this further. It works, but it is not ideal. 

    Can we accomplish this with masking?

    This article https://www.jotform.com/help/381-Getting-Started-with-the-Basics-of-Input-Masking shows an example of, "You could even include the St. in the Mask if you wanted:"

    However, the example they give assumes that every city will have 9 characters after the "St ".

    People entering a URL for a book image could have a URL of any length, including extremely long. 

    The article gives these choices:

           @  =   Masks Letters

           #    =   Masks Numbers

           *    =   Masks Letters & Numbers

    However, it does not give a choice of a character that is neither a letter or number (for instance, a dot or a slash or a dash, all of which might appear in a URL.

    It also does not give a character that lets the person enter any number of characters, instead of an exact count.

    I hope there is an undocumented option, such as '!' which would let the person enter any number of anything.

    I added a field called URL test where I could experiment, and I hid it with this Condition so that you can see it if you look in build, but visitors will not see it. It is based on Get Page URL Contains value = testing, which never occurs.

    Thanks! And Happy New Year to all of you at Jotform.


  • Profile Image
    Nik_C
    Answered on January 01, 2018 at 03:51 AM

    I'm afraid that is not possible since masks are usually used for phone numbers, addresses. 

    Maybe a validation of the field could work:

    1514796425Screen Shot 2018-01-01 at 9.53

    Although you need to check https so that will not work fully, so a combination with the condition might work:

    1514796629Screen Shot 2018-01-01 at 9.55

    So you can show an error message (maybe even hide the submit button) until the right URL is entered.

    Hope it helps.

    Thank you!

  • Profile Image
    rtolmach
    Answered on January 01, 2018 at 11:42 AM

    Thanks! The idea of hiding the submit button is really clever!

     

    Would you please pass this suggestion along to your product team? It would be very easy to implement, and it would make masking MUCH more useful.

    You currently allow the following:

    @  =   Masks Letters

    #    =   Masks Numbers

    *    =   Masks Letters & Numbers

    Each of those(@, #, and *) represents just one character that can be entered. That does not work in scenarios where the form calls for info that is not always of the same length. Indeed, Example A at https://www.jotform.com/help/381-Getting-Started-with-the-Basics-of-Input-Masking actually demonstrates the problem, since it assumes that every city starting with "St" has 9 characters after the space. That is clearly not the case. 

    It would make the masking tool much more useful if it allowed these additional options:

    [@]  =   Allows visitor to enter any number of letters This would be a better way to accommodate Example A, above, asking for a city of any length starting with "St". The form creator would designate:  St [@], and the visitor could enter St Augustine, St Lucia, or St Miguel 

    [#]    =   Allows visitor to enter any number of Numbers  This would be a better way to accommodate a serial number that starts with a letter and might be of any length. If the serial numbers all start with a single letter, then the form creator would designate:  @[#]. If the serial numbers might have one, two, or three letters, followed by a number of any length, the form creator would designate:  [@][#].

    [*]    =   Allows visitor to enter any number of Letters & Numbers

    This would be a better way to accommodate data that starts with a specified letter and might have a combination of letters and numbers and might be of any length. For instance, if the serial numbers all start with AB, then the form creator would designate:  AB[*]. That allows the entry of serial numbers AB12-345 and AB13726. If the serial numbers might have one, two, or three letters, followed by a number of any length, the form creator would designate:  [@][#].

    There is one more condition that needs to be addressed: allowing characters other than numbers of letters, as in the case where we want visitors to submit a URL, and we want to require https://, so we cannot just validate to confirm it is a URL. Of course a URL might be of any length, and it might include such characters as:

    :  /  .  -  _  ?  and #

    You might use another character for "ANY character", preferably one that is not likely to appear in any data a visitor enters. That might be ! or |, and the multiple-version would be [!] or [|].

     

    BTW, I suggested square brackets instead of parentheses to indicate that there can be any number of whichever type of characters because a form would be less likely to call for data that includes square brackets than in parentheses. You could likewise use {curly brackets}.

     

    I hope your product team will implement this. It seems easy enough to do, and it would add a lot of functionality.

     

    Thanks, and Happy New Year!

    Robert