URL validation code

Discussion in 'Article Script / Article Directory Script' started by graphixzonne, Jan 21, 2013.

  1. graphixzonne

    graphixzonne New Member

    Hi,
    someone who can help me?
    in "Article directory script"
    I added a field where the user have to enter a URL, but I need validation code for that field be mandatory ....

    I'm no programmer .. so I have no idea
    thanks for any help ..
  2. Vasily_B.

    Vasily_B. Project Manager

    Hi,

    You can add the following check for your field:
    PHP:

    $iaCore = iaCore::instance();
    if (!isset($_POST['url_field']) || empty($_POST['url_field'))
    {
    $error = true;
    $msg[] = iaLanguage::get('url_field_incorrect');
    }
     
    where url_field is the name of your field.
  3. graphixzonne

    graphixzonne New Member

    HI Vasily B.
    Thanks for your answer, but not worked, does not validate the field.
    I changed "url_field" with "linkdelperfil" which is the name of the field ... and also I changed "url_field_incorrect" with "link_incorrect" which a phrase I added ... still does not work for me.
  4. graphixzonne

    graphixzonne New Member

    As information, when creating new Articles and trying fill the url field
    Appears by default "http://" and even if I delete the item (http://) continues to be published
    without making mandatory filling.
    View attachment 76
  5. Vasily_B.

    Vasily_B. Project Manager

    Could you please create a ticket with your server details in our helpdesk?
    We would check the issue and post the results here. Thanks!
  6. graphixzonne

    graphixzonne New Member

    Hi Vasily B.
    I created the ticket and attached data with information
    thanks you for the help
  7. Gleb_S.

    Gleb_S. Subrion Designer Staff Member

    Ticket is replied. For those who are interested in the fix: please use the instructions below.

    Open edit page for a certain field in Admin Panel -> Manage Fields and add this code to the "Extra Actions" field:

    PHP:

    if (!iaValidate::isUrl($_POST['url_field']['url']))
    {
        $error = true;
        $msg[] = iaLanguage::get('url_field_incorrect');
    }
     
    where url_field is the name of the field.

    Save the changes.
  8. graphixzonne

    graphixzonne New Member

    Alex B.
    Vasily B.
    Thanks for the help

    now is working properly, great support...
  9. Vasily_B.

    Vasily_B. Project Manager

    Our pleasure, don't hesitate to contact us if you have any questions!

Share This Page