{"id":8734,"date":"2024-05-09T12:46:31","date_gmt":"2024-05-09T11:46:31","guid":{"rendered":"https:\/\/www.verificaremails.com\/kb\/how-to-use-the-widget-to-validate-forms\/"},"modified":"2025-02-03T23:33:00","modified_gmt":"2025-02-03T22:33:00","slug":"how-to-use-the-widget-to-validate-forms","status":"publish","type":"kb","link":"https:\/\/www.verificaremails.com\/en\/kb\/how-to-use-the-widget-to-validate-forms\/","title":{"rendered":"How to use the widget to validate forms"},"content":{"rendered":"<p>At Verificaremails we have developed a widget to validate forms that allows you to verify in real time the data you capture through Web forms. Using our wizard you can implement verification services on any web form to verify emails, validate phone numbers, postal addresses, names and surnames.<\/p>\n<h2>Where should I create the Widget to validate forms?<\/h2>\n<p>In order to implement the widget in any form, you must log in to our portal and select in the left side menu the &#8220;<a href=\"https:\/\/dashboard.verificaremails.com\/app\/user_widgets\" target=\"_blank\" rel=\"nofollow noopener\">WidgetJS<\/a>&#8221; section.<\/p>\n<p>A view will be displayed where you will see the active widgets and you can create new ones using the top button &#8220;+Create new widget&#8221;.<\/p>\n<p>In order to use the widget you need to have an API of the service you want to use. Remember that you can simultaneously use several verification services to validate together: names, emails, phone numbers&#8230;<\/p>\n<h2>Form Verification Widget Configuration<\/h2>\n<p>Before you start, we recommend that you watch the video on how the service works. Implementing the Widget is not complex, but requires a minimum of technical knowledge. Using a widget for verification allows to reduce the implementation of the verification service in a form from days\/hours to minutes.<\/p>\n<p><img fetchpriority=\"high\"  decoding=\"async\" class=\"size-full wp-image-8691 aligncenter\" src=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-182643.webp\" alt=\"Widget verification forms\" width=\"1190\" height=\"732\" srcset=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-182643.webp 1190w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-182643-300x185.webp 300w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-182643-1024x630.webp 1024w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-182643-768x472.webp 768w\" sizes=\"(max-width: 1190px) 100vw, 1190px\" \/><\/p>\n<h3>Step 1 &#8211; Introduction<\/h3>\n<p>First, you must enter a name to identify the Widget. Use a name that allows you to identify to which forms you apply the field verification. Remember that you can check more than one field in the same form.<\/p>\n<h3>Step 2 &#8211; Select services<\/h3>\n<p>If you have previously created the APIs for the fields you want to verify, they will be listed under each service. If you have not created them yet, you must go to the <a href=\"https:\/\/dashboard.verificaremails.com\/app\/user_my_apis\" target=\"_blank\" rel=\"nofollow noopener\">APIs section<\/a> with the navigation menu on the left.<\/p>\n<p><img  decoding=\"async\" class=\"size-full wp-image-8695 aligncenter\" src=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-182658.webp\" alt=\"Selection of verification service in widget\" width=\"1185\" height=\"736\" srcset=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-182658.webp 1185w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-182658-300x186.webp 300w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-182658-1024x636.webp 1024w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-182658-768x477.webp 768w\" sizes=\"(max-width: 1185px) 100vw, 1185px\" \/><\/p>\n<h3>Step 3 &#8211; Configure services<\/h3>\n<p>For each of the services you will have to select if you only validate the fields with validation result &#8220;OK&#8221; or if you also accept the doubtful ones. For example, in the case of e-mail address verification. You may have emails that pass validation. In this case it will be marked as &#8220;OK&#8221; but we can also have dubious mails such as those that return &#8220;ok_for_all&#8221; or &#8220;accept_all&#8221;. We have grouped this type of mail under the category &#8220;Inconclusive&#8221;.<\/p>\n<p><img  decoding=\"async\" class=\"size-full wp-image-8699 aligncenter\" src=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183224.webp\" alt=\"Select verification service in widget for forms\" width=\"1190\" height=\"747\" srcset=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183224.webp 1190w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183224-300x188.webp 300w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183224-1024x643.webp 1024w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183224-768x482.webp 768w\" sizes=\"(max-width: 1190px) 100vw, 1190px\" \/><\/p>\n<p>You must decide if you are going to let the user register this type of mails. This does not mean that the email address is invalid. We simply cannot reliably verify it. The same applies to the other fields: telephone numbers, postal addresses, names&#8230;<\/p>\n<p>In the section <strong>&#8220;DOM selectors of the elements&#8221;<\/strong> we identify the DOM element that contains the field to validate, in our case the mail. There are several ways to define this field.<\/p>\n<p>For our example if we have a form, where the form has an <strong>id=&#8221;frmSS134&#8243;<\/strong> and the value that contains the email field is called <strong>name=&#8221;email&#8221;<\/strong>.<\/p>\n<p>Ex:<br \/>\n<em>&lt;form method=&#8221;post&#8221; action=&#8221;https:\/\/www.marketingdeexperiencias.com\/iris\/form.php?form=134&#8243; id=&#8221;frmSS134&#8243; onsubmit=&#8221;return CheckForm134(this);&#8221;&gt;<\/em><br \/>\n<em>&lt;table border=&#8221;0&#8243; cellpadding=&#8221;2&#8243;&gt;<\/em><br \/>\n<em>&lt;tr&gt;<\/em><br \/>\n<em>&lt;td&gt;&lt;span&gt;*&lt;\/span&gt; <\/em><br \/>\n<em>Your email address:&lt;\/td&gt;<\/em><br \/>\n<em>&lt;td&gt;&lt;input type=&#8221;text&#8221; name=&#8221;email&#8221; value=&#8221;&#8221; \/&gt;&lt;\/td&gt;<\/em><\/p>\n<p>In the field &#8220;DOM selectors of the elements&#8221; we should enter<br \/>\n<strong># frmSS134 [name=\u2019email\u2019]<\/strong><\/p>\n<p><img loading=\"lazy\"  decoding=\"async\" class=\"alignnone size-full wp-image-8703\" src=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183242.webp\" alt=\"DOM widget for forms\" width=\"811\" height=\"148\" srcset=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183242.webp 811w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183242-300x55.webp 300w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183242-768x140.webp 768w\" sizes=\"(max-width: 811px) 100vw, 811px\" \/><\/p>\n<p>If you do not know how to identify it, the easiest way is to put in &#8220;id&#8221; to the HTML field that contains the field to validate. You must indicate this field as #field_name.<\/p>\n<p>For example, if we have an &#8220;email&#8221; field defined as:<\/p>\n<p><em>&lt;input type=&#8221;text&#8221; id=field_name name=&#8221;email&#8221; value=&#8221;&#8221; \/&gt;<\/em><\/p>\n<p>In this case, we must enter in the <strong>&#8220;DOM selectors of the elements&#8221;<\/strong> field<br \/>\n<strong># field_name<\/strong> (the name must start with a letter)<\/p>\n<p><img loading=\"lazy\"  decoding=\"async\" class=\"alignnone size-full wp-image-8707\" src=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183731.webp\" alt=\"DOM ID input field for widget in forms\" width=\"820\" height=\"157\" srcset=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183731.webp 820w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183731-300x57.webp 300w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-183731-768x147.webp 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/p>\n<p>Instead of &#8220;ID&#8221;, we can also use classes to identify the fields:<br \/>\n<strong>.my_form .my_field<\/strong><\/p>\n<p>Another combination is to use the form identifier with the name of the field, leaving:<br \/>\n<strong>#mi_formulario . [name=\u2019nombre_del_campo\u2019]<\/strong><\/p>\n<p>If all this is too complicated, pass this information to your developer and he will integrate it without any problems. For someone who is used to working with CSS it should not be complicated.<\/p>\n<p>Using the Widget instead of having to do custom development allows you to implement form verification functionality in minutes rather than having to spend hours of work implementing your own verification service.<\/p>\n<h3>Step 4 &#8211; Error configuration<\/h3>\n<p>In this section we are going to configure how to display error messages. We can change the styles on how to display fields that have errors through the <strong>&#8220;Error type&#8221;<\/strong> field. Here we have to decide if we are going to use <strong>&#8220;Styles&#8221;<\/strong> or <strong>&#8220;Classes&#8221;<\/strong> to indicate that there is an error in the form.<\/p>\n<p><img loading=\"lazy\"  decoding=\"async\" class=\"alignnone size-full wp-image-8711\" src=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-192029.webp\" alt=\"Selection of styles and classes in widget for forms\" width=\"882\" height=\"453\" srcset=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-192029.webp 882w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-192029-300x154.webp 300w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-08-192029-768x394.webp 768w\" sizes=\"(max-width: 882px) 100vw, 882px\" \/><\/p>\n<p>In our case we have selected &#8220;Styles&#8221;. This allows us to directly indicate the styles in the wizard. To prevent the validation process from affecting the form&#8217;s registration ratio, we have made the field check triggered in the &#8220;change focus&#8221; event.<\/p>\n<p>In our case what we will do is that the form will show a red line in the field that fails at the moment that the user changes the focus from the &#8220;email&#8221; field to another element.<\/p>\n<p>In this same section we have two additional options. The <strong>&#8220;Manage form submission&#8221;<\/strong> which allows you to block the submission of data until they are invalid. Remember that we can define what is valid data for each service in the <strong>&#8220;Configure services&#8221;<\/strong> option. If we disable the <strong>&#8220;Manage form submission&#8221;<\/strong> option the developer can use the <strong>&#8220;await widgetJS.isFormValid(#myform)&#8221;<\/strong> functions to capture and manage the verification states.<\/p>\n<p>An additional field is &#8220;<strong>Allow to submit form with errors&#8221;<\/strong>. Here we can define how many times the user can send invalid data before saving it. We will use this option if we are interested in saving the data, even if they are partially erroneous.<\/p>\n<h3>Step 5 &#8211; Authorized domains.<\/h3>\n<p>In this option we will indicate in which domains the option to verify data can be used when verifying forms. This adds an extra level of security, preventing them from using the verification credentials for purposes other than verification on our website.<\/p>\n<p><img loading=\"lazy\"  decoding=\"async\" class=\"alignnone size-full wp-image-8715\" src=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-114800.webp\" alt=\"Authorized domains widget form\" width=\"814\" height=\"155\" srcset=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-114800.webp 814w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-114800-300x57.webp 300w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-114800-768x146.webp 768w\" sizes=\"(max-width: 814px) 100vw, 814px\" \/><\/p>\n<p>We recommend that you limit the number of <a href=\"https:\/\/dashboard.verificaremails.com\/app\/user_my_apis\" target=\"_blank\" rel=\"nofollow noopener\">API requests<\/a>, per minute and total requests as an additional level of security.<\/p>\n<h3>Step 6 &#8211; Completed.<\/h3>\n<p>At this point we must copy and paste the code generated by the wizard in the page where we have our form. We recommend publishing it after the onesie.<\/p>\n<p><img loading=\"lazy\"  decoding=\"async\" class=\"alignnone size-full wp-image-8719\" src=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-120027.webp\" alt=\"Forms embed widget code\" width=\"835\" height=\"112\" srcset=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-120027.webp 835w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-120027-300x40.webp 300w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-120027-768x103.webp 768w\" sizes=\"(max-width: 835px) 100vw, 835px\" \/><\/p>\n<p>For those of you who have a non-standard system, we have created a <strong>&#8220;maximum compatibility&#8221;<\/strong> version. This allows to make the verification widget even more compatible. You must place a part of the script inside the header of the page where the form is placed. If you can restrict this script in the page where you have the form much better, although the script is very fast it will always require a few milliseconds of processing.<\/p>\n<p><img loading=\"lazy\"  decoding=\"async\" class=\"alignnone size-full wp-image-8723\" src=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-120331.webp\" alt=\"Maximum forms widget compatibility script\" width=\"886\" height=\"362\" srcset=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-120331.webp 886w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-120331-300x123.webp 300w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-120331-768x314.webp 768w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/p>\n<p>To launch the verification script you must also add the maximum compatibility script. This ensures that the verification functionalities are launched exclusively on the indicated page. Do not make them appear on every page of your website. This unnecessarily slows down the loading speed of the Web in sections where it is not used and our firewall can block the checks if the number of requests is too high by interpreting it as an attack.<\/p>\n<p><em>&lt;script&gt;widgetJS.enableMaxCompatibility();&lt;\/script&gt;<\/em><\/p>\n<h3>Safety considerations<\/h3>\n<p>Remember when using a Widget you are exposing the API token. It is good that you only enable the domains where you want to display the form (defined in the <strong>&#8220;Authorized domains&#8221;<\/strong> section of the Widget configuration and that you also limit the total requests and requests per minute that the Widget can process. Set it to a number that makes sense for your usage pattern.<\/p>\n<p><img loading=\"lazy\"  decoding=\"async\" class=\"alignnone size-full wp-image-8727\" src=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-115818.webp\" alt=\"Security API verification services\" width=\"785\" height=\"581\" srcset=\"https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-115818.webp 785w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-115818-300x222.webp 300w, https:\/\/www.verificaremails.com\/wp-content\/uploads\/2024\/05\/Captura-de-pantalla-2024-05-09-115818-768x568.webp 768w\" sizes=\"(max-width: 785px) 100vw, 785px\" \/><\/p>\n<p>If you need help with the implementation of the Widget to validate forms, you can contact us through the chat assistant that you will find at the bottom right of the Web.<\/p>\n<p>Remember that you can evaluate for free the <a href=\"https:\/\/www.verificaremails.com\/en\/\">service to validate emails<\/a> by registering in our portal.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At Verificaremails we have developed a widget to validate forms that allows you to verify in real time the data you capture through Web forms. Using our wizard you can implement verification services on any web form to verify emails, validate phone numbers, postal addresses, names and surnames. Where should I create the Widget to &#8230; <a title=\"How to use the widget to validate forms\" class=\"read-more\" href=\"https:\/\/www.verificaremails.com\/en\/kb\/how-to-use-the-widget-to-validate-forms\/\" aria-label=\"Read more about How to use the widget to validate forms\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"kbtopic":[1127,1050],"kbtag":[1105],"class_list":["post-8734","kb","type-kb","status-publish","hentry","kbtopic-api-services","kbtopic-apiservicios","kbtag-widget-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/kb\/8734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/comments?post=8734"}],"version-history":[{"count":0,"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/kb\/8734\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/media?parent=8734"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/kbtopic?post=8734"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.verificaremails.com\/en\/wp-json\/wp\/v2\/kbtag?post=8734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}