Setting Up Form Field Validation in 1C-Bitrix

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Showing 1 of 1All 1626 services
Setting Up Form Field Validation in 1C-Bitrix
Simple
~1 day
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1360
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    948
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    694
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    832
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    732
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    1075

Setting Up Form Field Validation in 1C-Bitrix

We encounter this constantly. Clients arrive with a ready-made contact catalog where each manager entered data however they wanted. As a result, no automatic export works. The solution is to set up validation at the form filling stage. Here we show how to bring order to data using 1C-Bitrix tools: from input masks to server handlers. Our experience — over 50 validation projects, each delivered turnkey with a guaranteed result. Validation setup starts from $200 per form and reduces erroneous records by up to 90%. For a typical 5-field form, investment ranges from $300 to $500, eliminating thousands in manual data cleaning costs annually.

The form accepts a phone number in any format: "80291234567", "+375-29-123-45-67", "029 123 45 67" — all of it lands in the database as is. Three months later, a manager looks at 2000 records with numbers in ten different formats and cannot upload them to the CRM. If validation had been set up in advance, the data would have arrived normalized. Let's examine the tools that ensure this.

Why Standard Validation Is Not Enough

1C-Bitrix's built-in tools provide basic checks but do not solve all problems. They cannot flexibly respond to non-standard formats, do not normalize data, and do not protect against bots. For full-featured validation, you need to combine several approaches: from masks to server-side handlers. According to 1C-Bitrix documentation, the OnBeforeResultAdd event is the primary point for server-side validation.

Step-by-Step Validation Setup

  1. Analyze form fields – Identify which fields need validation (phone, email, date, etc.) and their required formats.
  2. Choose validation methods – Decide on client-side masks, JavaScript validation, and server-side checks. For example, phone fields often use both a mask and a server regex.
  3. Implement client-side validation – Add input masks with IMask.js and JavaScript submit handlers for instant feedback.
  4. Write server-side handlers – Use OnBeforeResultAdd to normalize data and reject invalid entries.
  5. Test with boundary values – Test with direct POST requests, empty fields, and extreme inputs to ensure robustness.

Built-in Validation of the Form Module

The form module supports basic validation at the field level via parameters in b_form_field: the REQUIRED (Y/N) field, the CHECK_FILTER field — a regular expression for value checking, and the FILTER_MEMO field — an error message.

Editing via API:

\CFormField::Update($fieldId, $formId, [
    'REQUIRED'     => 'Y',
    'CHECK_FILTER' => '^\\+375[0-9]{9}$',
    'FILTER_MEMO'  => 'Enter the number in the format +375XXXXXXXXX',
]);

CHECK_FILTER is checked on the server when the result is saved. Client-side validation is not supported by the built-in module — only server-side.

Comparison of Validation Approaches

Method Where Executed Response Time Protection Against Direct POST Erroneous Records Reduction
Input mask Client Instant No <5%
JavaScript validation Client <100 ms No <10%
Server-side validation Server 500–1000 ms Yes >99%
reCAPTCHA Server 200–500 ms Yes (bots) Up to 95% spam reduction

An input mask catches typos 5 times faster than a server-side check after submission. However, only server-side validation guarantees protection against direct POST requests.

Common Field Validation Patterns

Field Type Example Mask Server Regex
Phone +{375} (00) 000-00-00 ^\+375[0-9]{9}$
Email (no mask) ^[^\s@]+@[^\s@]+.[^\s@]+$
Date 00.00.0000 ^\d{2}.\d{2}.\d{4}$
Numeric (custom) ^\d+(.\d+)?$

Client-Side Validation via JavaScript

For immediate feedback, front-end validation is added to the template of the bitrix:form.result.new component. The handler subscribes to the form submit event:

document.getElementById('form_<?= $arResult['FORM']['SID'] ?>').addEventListener('submit', function (e) {
    var errors = [];

    // Phone
    var phone = document.getElementById('field_PHONE').value.replace(/\D/g, '');
    if (!/^375\d{9}$/.test(phone)) {
        errors.push('Phone: enter the number in the format +375XXXXXXXXX');
        document.getElementById('field_PHONE').classList.add('error');
    }

    // Email
    var email = document.getElementById('field_EMAIL').value;
    if (email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
        errors.push('Email: invalid address format');
        document.getElementById('field_EMAIL').classList.add('error');
    }

    if (errors.length > 0) {
        e.preventDefault();
        document.getElementById('form_errors').innerHTML = errors.join('<br>');
    }
});

Normalization Before Saving

Validation without normalization is a half solution. The phone number should not only be checked but also brought to a unified format. Handler for the OnBeforeResultAdd event:

AddEventHandler('form', 'OnBeforeResultAdd', function($formId, &$arFields) {
    if (isset($arFields['form_field_PHONE'])) {
        $phone = preg_replace('/\D/', '', $arFields['form_field_PHONE']);

        // Normalize: 80291234567 → 375291234567
        if (strlen($phone) === 11 && $phone[0] === '8') {
            $phone = '375' . substr($phone, 2);
        }
        if (strlen($phone) === 9) {
            $phone = '375' . $phone;
        }

        if (strlen($phone) === 12 && str_starts_with($phone, '375')) {
            $arFields['form_field_PHONE'] = '+' . $phone;
        } else {
            global $APPLICATION;
            $APPLICATION->ThrowException('Invalid phone number format');
            return false;
        }
    }
});

Validation Using Input Masks

An input mask prevents incorrect format during input. The IMask.js library is integrated into the component template:

IMask(document.getElementById('field_PHONE'), {
    mask: '+{375} (00) 000-00-00',
});

With the mask, the user physically cannot enter a letter in the phone field. This removes part of the load from back-end validation, but does not replace it — data can come via a direct POST request bypassing the form.

Spam Protection

Bitrix's standard CAPTCHA is enabled via the component parameter USE_CAPTCHA. For web forms, use a field of type captcha in b_form_field. An alternative is Google reCAPTCHA v3 via the OnBeforeResultAdd handler: with a low reCAPTCHA score, the form is silently rejected (honeypot approach for bots). Our implementations show spam reduction of up to 95%.

Server-side reCAPTCHA v3 check:

$token = $_POST['g-recaptcha-response'];
$response = file_get_contents(
    'https://www.google.com/recaptcha/api/siteverify?secret=SECRET&response=' . $token
);
$data = json_decode($response, true);
if ($data['score'] < 0.5) {
    return false; // Silently reject
}

Deliverables

Our specialists, with over 10 years of experience with 1C-Bitrix, perform a full analysis of the form, develop regular expressions and masks, configure server handlers and spam protection. Everything is tested on real scenarios. Upon completion, you receive documentation and an administrator's guide. We guarantee that data will come in a unified format and erroneous records will be minimized to <1%.

What You Get

  • Analysis: Review of current fields and data requirements
  • Development: Regular expressions and masks for each field
  • Implementation: Front-end validation (JavaScript) and back-end handlers
  • Anti-spam: Integration of reCAPTCHA v3 or custom honeypot fields
  • Testing: Boundary value testing and direct POST request verification
  • Deliverables:
    • Validation specification document
    • JavaScript code for front-end validation
    • PHP handlers for server-side normalization
    • reCAPTCHA v3 integration code
    • Test report with before/after error rates
    • Administrator's guide (PDF)
    • Training session for your team (1 hour)
    • Access to our support portal for issue tracking
    • 1 month post-launch support

How Long Does Setup Take?

Timelines depend on the number of fields and complexity of logic. On average, configuring one field takes from 2 hours; comprehensive validation of a form (up to 10 fields) takes 2 to 5 days. Project estimation is free. Contact us to discuss details and choose the best solution for your business.

Common edge cases: leading/trailing spaces, characters in numeric fields, empty required fields. These are caught by trimming spaces before server validation and setting appropriate regex patterns.

What Professional 1C-Bitrix Installation Includes

We start by checking innodb_buffer_pool_size. The default MySQL value (128 MB) is a death sentence for an online store with a catalog of 10,000+ items. We set 70–80% of available RAM on a dedicated server, 50% on VPS. This single setting speeds up the site by 2–3 times compared to the default. We'll assess your project in one day — get a consultation. Contact us to order turnkey installation with performance guarantee.

How to Choose Hosting and Edition for 1C-Bitrix Installation?

BitrixVM is a virtual machine with a pre-installed stack: nginx + Apache, PHP-FPM, MySQL/MariaDB, Sphinx, Push server. For VPS — the best start. Everything is already configured for Bitrix, including OPcache, log rotation, and firewall. Management via web panel on port 8890. Bitrix documentation recommends starting with BitrixVM for predictable performance.

VPS/VDS is the sweet spot. Minimum configuration for a medium online store: 2 vCPU, 4 GB RAM, SSD. Optimal: 4 vCPU, 8 GB RAM. OS: Ubuntu 22.04 or Debian 12. If not BitrixVM, we configure the stack manually for the task. Virtual hosting — only for business cards and landing pages. Requirements: PHP 8.0+, MySQL 5.7+ / MariaDB 10.0+, 512 MB RAM, .htaccess. 1C-Bitrix hosting partners guarantee compatibility. Dedicated server — for highload. Typical architecture: web server separate, database separate, Redis/Memcached separate. For Enterprise edition — web cluster with load balancer. Cloud (Yandex Cloud, VK Cloud, Selectel) — when load spikes: sales, seasonal peaks. Autoscaling via Managed Kubernetes or simple VM vertical scaling.

Choosing the edition is equally important. A common mistake: choosing "Small Business" for a store that grows to B2B with wholesale prices and three warehouses in six months. Upgrading to "Business" — pay the difference, data is not lost, but it's better to plan ahead. Our specialists select the edition for current tasks and with room for growth. For example, the "Business" license (about 35,000 RUB) pays off through multi-warehouse and 1C exchange, while the wrong choice can lead to a loss of up to 30,000 RUB monthly on excess resources.

Edition For Whom Key Limitation
Start Business cards, landing pages No infoblocks 2.0, no trade catalog
Standard Corporate sites No e-commerce module
Small Business Small stores 1 price type, 1 warehouse, no 1C exchange
Business Medium stores, B2B Multi-warehouse, multicurrency, CommerceML
Enterprise Highload, cluster Web cluster, CDN, multisite

What Server Settings Are Critical for 1C-Bitrix?

Web Server and PHP

nginx as reverse proxy + Apache (mod_php) or nginx + PHP-FPM directly. The second option saves memory — Apache is not needed. But some Bitrix modules use .htaccess, so for compatibility we sometimes keep Apache. nginx configuration: fastcgi_read_timeout 300 — for long operations (1C import), client_max_body_size 1024m — large file uploads. Block access to .settings.php, .settings_extra.php, bitrix/.settings.php — they contain database passwords. Rewrite rules from urlrewrite.php — Bitrix generates them, but with nginx + PHP-FPM they need to be duplicated. PHP 8.0–8.2 with extensions: mbstring, curl, gd, xml, json, opcache, redis/memcached. Key php.ini settings: opcache.memory_consumption=256, opcache.max_accelerated_files=20000, max_execution_time=300, memory_limit=512M, upload_max_filesize=100M, post_max_size=128M.

Database and Caching

MySQL/MariaDB. Key my.cnf parameters: innodb_buffer_pool_size — 70–80% RAM, innodb_log_file_size=256M, tmp_table_size=256M, max_heap_table_size=256M, thread_pool_size — number of CPU cores. Encoding utf8mb4 mandatory, otherwise emoji and special characters break. Redis is preferable to Memcached for Bitrix — supports persistent connections and is more reliable. In production, Redis handles concurrent writes three times faster than Memcached under typical load. Configure in .settings_extra.php:

'cache' => ['value' => ['type' => ['class_name' => '\\Bitrix\\Main\\Data\\CacheEngineRedis']]]
'session' => ['value' => ['mode' => 'default', 'handlers' => ['general' => ['type' => 'redis']]]]
Example Redis configuration for Bitrix
sudo apt install redis-server
sudo systemctl enable redis

Add to .settings_extra.php as above.

SSL, Email, and Cron

SSL — Let's Encrypt via certbot in 90% of cases. Redirect HTTP → HTTPS (301), HSTS, TLS 1.2/1.3, OCSP Stapling. In Bitrix, switch to HTTPS in the main module settings. Email: abandon mail() — connect SMTP (Yandex.Mail for domain, Mail.ru for Business). Be sure to configure SPF, DKIM, DMARC. Without SPF, emails go to spam. Test deliverability via mail-tester.com — score 9+/10. Cron: Bitrix agents switch to system cron — * * * * * /usr/bin/php /var/www/bitrix/modules/main/tools/cron_events.php. Schedule 1C exchange (15–60 min), search reindex, backups (mysqldump + rsync, rotation 7+4), temporary file cleanup.

Security and Administration

File system: owner www-data, directories 755, files 644, upload 775. nginx blocks access to configuration files. Enable Bitrix Proactive Protection — WAF, activity control (block after 5 failed attempts), kernel integrity check. For admin panel: two-factor authentication via Google Authenticator or OTP, restrict access by IP via nginx for paranoid.

How Long Does 1C-Bitrix Installation and Configuration Take?

Task Timeline
Installation on virtual hosting 2–4 hours
Installation on VPS with stack configuration 1–2 days
Installation on dedicated with architecture design 2–5 days
SSL + email + cron + security 1–2 days
Backup and monitoring setup 0.5–1 day

Post-Installation Checklist

  1. Performance Monitor (/bitrix/admin/perfmon_panel.php) — aim for 30+ points. Below 20 means serious configuration issues.
  2. System Check — automatic check of all parameters. Red items must be fixed, yellow — case by case.
  3. Security Scanner — check for typical vulnerabilities.
  4. PageSpeed Insights — TTFB < 200ms on VPS, LCP < 2.5s.
  5. Test 1C exchange — if integration is planned, verify CommerceML exchange before launch.

Additionally, check software versions, caching settings, cron operation, SSL certificate, SPF/DKIM/DMARC, access rights, delete default users and pages. For projects with 54-FZ, ensure fiscalization is configured via OFD provider.

Deliverables

  • Fully configured server for 1C-Bitrix with MySQL, PHP, nginx optimization.
  • Installed and activated license of the required edition.
  • SSL certificate, email settings, cron and backups.
  • Documentation: all configuration parameters, access credentials, cron tasks.
  • Content manager training: how to log into admin panel, add products, upload images.
  • Post-installation support for 30 days — consultations on settings.

Why Trust Professionals with Installation?

Incorrect installation means lost time and money. We've seen projects where a store on "Start" couldn't handle 50 visitors because innodb_buffer_pool_size wasn't configured. After migrating to VPS with correct configuration, the site "flew". Incorrect configuration can cost 30,000 RUB monthly due to excessive resource consumption. You get a ready-made architecture that scales. Order turnkey 1C-Bitrix installation — get a reliable platform for business growth. Contact us for a free consultation: we'll calculate the cost and time for your project. Over 7 years of experience, 120+ Bitrix projects implemented, including highload stores with million-item catalogs. Get in touch — we'll help configure Bitrix for your project.