{"id":20932,"date":"2026-11-20T23:28:37","date_gmt":"2026-11-20T17:58:37","guid":{"rendered":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/"},"modified":"2026-11-20T23:28:37","modified_gmt":"2026-11-20T17:58:37","slug":"otp-widget-popup-button-mobile-field","status":"publish","type":"post","link":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/","title":{"rendered":"OTP popup on button click, Verify button on your mobile field and form protect (OTP widget)"},"content":{"rendered":"<p>To show an <strong>OTP popup on button click<\/strong>, add <code>data-f2s-otp-popup=\"YOUR_WIDGET_KEY\"<\/code> to your own button and load the Fast2SMS widget script once on the page. When a visitor clicks the button, the free OTP widget opens in a popup, they verify their mobile number, and the popup closes. This page covers all four install modes of the hosted OTP widget: the inline widget, a popup on your own button, a <strong>Verify<\/strong> button next to your own mobile field, and a protected form. It ends with the JavaScript events your page can listen to.<\/p>\n<aside class=\"f2s-cta\" aria-label=\"Get started with Fast2SMS\"><div class=\"f2s-cta__copy\"><strong class=\"f2s-cta__title\">Add an OTP popup to your website<\/strong><p>Create a free OTP widget in Smart OTP and open it from any button on your site.<\/p><\/div><div class=\"f2s-cta__actions\"><a class=\"f2s-cta__btn f2s-cta__btn--primary\" href=\"https:\/\/www.fast2sms.com\/\"><span>Sign up free<\/span> <span class=\"f2sh-btn__arrow\" aria-hidden=\"true\">&rarr;<\/span><\/a><a class=\"f2s-cta__btn f2s-cta__btn--ghost\" href=\"https:\/\/www.fast2sms.com\/meet\/\" target=\"_blank\" rel=\"noopener\">Book a free meeting<\/a><\/div><\/aside>\n<h2>Before you start<\/h2>\n<p>You need a widget first. If you have not made one, follow the <a href=\"https:\/\/www.fast2sms.com\/help\/free-otp-widget-for-website\/\">free OTP widget guide<\/a>: pick an approved OTP ID, list your websites and save. Every code on this page is in the widget&#8217;s <strong>Install<\/strong> tab, with your widget key filled in and a <strong>Copy<\/strong> button. The widget is free. Each OTP it sends, including tests, is charged at your Smart OTP rate.<\/p>\n<div class=\"f2s-note f2s-volume\"><p><strong>Sending in bulk?<\/strong> For high OTP volumes our team offers discounted rates. <a href=\"https:\/\/www.fast2sms.com\/meet\/\" target=\"_blank\" rel=\"noopener\">Talk to our team<\/a> or see <a href=\"https:\/\/www.fast2sms.com\/bulk-sms-pricing\">OTP pricing<\/a>.<\/p><\/div>\n<h2>The four install modes at a glance<\/h2>\n<div class=\"f2s-facts\">\n<table>\n<thead>\n<tr>\n<th>Install sub-tab<\/th>\n<th>Attribute<\/th>\n<th>The visitor sees<\/th>\n<th>Your page gets<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Widget<\/td>\n<td><code>data-f2s-otp-widget<\/code> on a div<\/td>\n<td>The widget inside the page<\/td>\n<td>The <code>f2s:verified<\/code> event with a token<\/td>\n<\/tr>\n<tr>\n<td>Popup<\/td>\n<td><code>data-f2s-otp-popup<\/code> on your button<\/td>\n<td>Your button; the widget opens in a popup<\/td>\n<td>The <code>f2s:verified<\/code> event, or your &#8220;after verify&#8221; page<\/td>\n<\/tr>\n<tr>\n<td>Mobile field<\/td>\n<td><code>data-f2s-otp-attach<\/code> on your mobile input<\/td>\n<td>A Verify button next to your own field<\/td>\n<td>A hidden <code>f2s_token<\/code> in the form; the form waits for verification<\/td>\n<\/tr>\n<tr>\n<td>Form<\/td>\n<td><code>data-f2s-otp-protect<\/code> on your form<\/td>\n<td>The widget inside your form<\/td>\n<td>A hidden <code>f2s_token<\/code> in the form; the form waits for verification<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>All four modes use the same script line. Add it once per page, even if you use more than one mode.<\/p>\n<h2>Mode 1: the inline widget<\/h2>\n<p>Put the <code>div<\/code> where the box should appear. This suits a page whose main job is verification, such as a login with mobile number or the first step of a sign-up.<\/p>\n<pre><code class=\"language-html\">&lt;script src=&quot;https:\/\/www.fast2sms.com\/widget\/otp-js?v=1.0.5&quot; defer&gt;&lt;\/script&gt;\n&lt;div data-f2s-otp-widget=&quot;YOUR_WIDGET_KEY&quot;&gt;&lt;\/div&gt;<\/code><\/pre>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-install-simple-hd-1-scaled.webp\" width=\"1440\" height=\"900\" loading=\"lazy\" decoding=\"async\" alt=\"Install tab, Widget sub-tab: Paste this on your website where the widget should show, with a Copy button and the script and div code\"><figcaption>Install, Widget: the inline box.<\/figcaption><\/figure>\n<h2>Mode 2: OTP popup on button click<\/h2>\n<p>Use this when you already have a button and want the check to happen only when someone clicks it, for example a cash on delivery button. Add the attribute to your button:<\/p>\n<pre><code class=\"language-html\">&lt;script src=&quot;https:\/\/www.fast2sms.com\/widget\/otp-js?v=1.0.5&quot; defer&gt;&lt;\/script&gt;\n&lt;button type=&quot;button&quot; data-f2s-otp-popup=&quot;YOUR_WIDGET_KEY&quot;&gt;Verify mobile&lt;\/button&gt;<\/code><\/pre>\n<p>The button can have any text and style. Keep <code>type=\"button\"<\/code> so it does not submit a form by itself. A click opens the widget over a dark backdrop with a close (&#215;) button. After the code is verified, the popup closes on its own a moment later.<\/p>\n<ol class=\"f2s-steps\">\n<li>\n<h3>Copy the Popup code<\/h3>\n<p>Open <strong>Install<\/strong> &gt; <strong>Popup<\/strong>. Choose a <strong>Popup position<\/strong> (Center is the default) and click <strong>Copy<\/strong>.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-install-popup-hd-scaled.webp\" width=\"1440\" height=\"900\" loading=\"lazy\" decoding=\"async\" alt=\"Install tab, Popup sub-tab: Your own button opens the widget in a popup, a Popup position dropdown set to Center, and the script and button code with a Copy button\"><figcaption>Install, Popup: pick a position, then copy.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>Your button sits on the page as usual<\/h3>\n<p>Nothing changes on the page until the visitor clicks. On this sample checkout, the button reads &#8220;Verify mobile and place order&#8221;.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-site-popup-hd.webp\" width=\"768\" height=\"326\" loading=\"lazy\" decoding=\"async\" alt=\"Sample Cash on delivery card: Confirm your number to place a COD order, with a dark button Verify mobile and place order\"><figcaption>Your own button on a sample cash on delivery page.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>The widget opens in a popup<\/h3>\n<p>The visitor types the number, clicks <strong>Send OTP<\/strong>, passes the short &#8220;I am human&#8221; check and types the 6-digit code.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-site-popup-open-hd.webp\" width=\"768\" height=\"580\" loading=\"lazy\" decoding=\"async\" alt=\"The OTP widget open in a popup over the dimmed COD page, with a close button, the Mobile number field with +91 and a Send OTP button\"><figcaption>The popup over your page.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>Verified, and the popup closes<\/h3>\n<p>&#8220;Mobile number verified&#8221; shows for a moment, then the popup closes. Your page hears the <code>f2s:verified<\/code> event (see below), or the visitor goes to the page set in <strong>After verify, open a page<\/strong>.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-site-popup-verified-hd.webp\" width=\"768\" height=\"546\" loading=\"lazy\" decoding=\"async\" alt=\"Popup showing a green tick with Mobile number verified and a Use a different number link\"><figcaption>The verified state before the popup closes.<\/figcaption><\/figure>\n<\/li>\n<\/ol>\n<h3>Popup positions<\/h3>\n<p>The popup can sit in 9 places. Pick one in <strong>Popup position<\/strong> before you copy, or set <code>data-f2s-position<\/code> on the button yourself:<\/p>\n<div class=\"f2s-facts\">\n<table>\n<thead>\n<tr>\n<th>data-f2s-position<\/th>\n<th>Where the popup shows<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>center (default)<\/td>\n<td>Middle of the screen<\/td>\n<\/tr>\n<tr>\n<td>top<\/td>\n<td>Top of the screen, centred<\/td>\n<\/tr>\n<tr>\n<td>bottom<\/td>\n<td>Bottom of the screen, centred<\/td>\n<\/tr>\n<tr>\n<td>left<\/td>\n<td>Left side, middle<\/td>\n<\/tr>\n<tr>\n<td>right<\/td>\n<td>Right side, middle<\/td>\n<\/tr>\n<tr>\n<td>top-left<\/td>\n<td>Top left corner<\/td>\n<\/tr>\n<tr>\n<td>top-right<\/td>\n<td>Top right corner<\/td>\n<\/tr>\n<tr>\n<td>bottom-left<\/td>\n<td>Bottom left corner<\/td>\n<\/tr>\n<tr>\n<td>bottom-right<\/td>\n<td>Bottom right corner<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<pre><code class=\"language-html\">&lt;button type=&quot;button&quot; data-f2s-otp-popup=&quot;YOUR_WIDGET_KEY&quot; data-f2s-position=&quot;bottom-right&quot;&gt;Verify mobile&lt;\/button&gt;<\/code><\/pre>\n<h2>Mode 3: a Verify button next to your own mobile field<\/h2>\n<p>If your form already asks for a mobile number, keep your field. Add <code>data-f2s-otp-attach<\/code> to it, and the script puts a <strong>Verify<\/strong> button next to it. The form submits only after that number is verified.<\/p>\n<pre><code class=\"language-html\">&lt;script src=&quot;https:\/\/www.fast2sms.com\/widget\/otp-js?v=1.0.5&quot; defer&gt;&lt;\/script&gt;\n&lt;form action=&quot;\/your-signup&quot; method=&quot;post&quot;&gt;\n  &lt;input name=&quot;name&quot; placeholder=&quot;Your name&quot;&gt;\n  &lt;input name=&quot;mobile&quot; type=&quot;tel&quot; data-f2s-otp-attach=&quot;YOUR_WIDGET_KEY&quot; placeholder=&quot;Mobile number&quot;&gt;\n  &lt;button type=&quot;submit&quot;&gt;Sign up&lt;\/button&gt;\n&lt;\/form&gt;<\/code><\/pre>\n<p>What happens on the page:<\/p>\n<ul>\n<li>A click on <strong>Verify<\/strong> opens the widget in a popup, with the number from your field already filled in.<\/li>\n<li>After a correct code, your field is locked, a green &#8220;Verified&#8221; tick appears and the button changes to <strong>Change<\/strong>.<\/li>\n<li>If the visitor edits the number, the verification is cleared and they verify again.<\/li>\n<li>If they click <strong>Sign up<\/strong> before verifying, the form does not submit and the popup opens.<\/li>\n<li>If they verify a different number inside the popup than the one in your field, the widget does not accept it and fires <code>f2s:error<\/code> with the reason <code>number_mismatch<\/code>.<\/li>\n<li>When verified, the form gets a hidden <code>f2s_token<\/code> field, the same as in Form mode.<\/li>\n<\/ul>\n<p>Three optional attributes change the button: <code>data-f2s-label<\/code> (button text, default &#8220;Verify&#8221;), <code>data-f2s-color<\/code> (a colour like #12aa9e) and <code>data-f2s-position<\/code> (where the popup opens, same 9 values as above).<\/p>\n<pre><code class=\"language-html\">&lt;input name=&quot;mobile&quot; type=&quot;tel&quot; data-f2s-otp-attach=&quot;YOUR_WIDGET_KEY&quot;\n       data-f2s-label=&quot;Verify number&quot; data-f2s-color=&quot;#1d4ed8&quot; data-f2s-position=&quot;top&quot;&gt;<\/code><\/pre>\n<ol class=\"f2s-steps\">\n<li>\n<h3>Copy the Mobile field code<\/h3>\n<p>Open <strong>Install<\/strong> &gt; <strong>Mobile field<\/strong>, choose a <strong>Popup position<\/strong> and click <strong>Copy<\/strong>. Move the attribute to the mobile input in your own form.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-install-attach-hd-scaled.webp\" width=\"1440\" height=\"900\" loading=\"lazy\" decoding=\"async\" alt=\"Install tab, Mobile field sub-tab explaining that a Verify button appears next to your mobile field, a Popup position dropdown and an example form with data-f2s-otp-attach on the mobile input\"><figcaption>Install, Mobile field: the attribute goes on your own input.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>The Verify button appears next to your field<\/h3>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-site-attach-hd.webp\" width=\"768\" height=\"504\" loading=\"lazy\" decoding=\"async\" alt=\"Sample Sign up form with Your name and a Mobile number field filled with 9000000001, a teal Verify button under the field and a Sign up button\"><figcaption>Your form with the Verify button added.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>The popup opens with the number filled in<\/h3>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-site-attach-open-hd.webp\" width=\"768\" height=\"580\" loading=\"lazy\" decoding=\"async\" alt=\"OTP widget popup over the sign-up form with the mobile number 9000000001 already filled in and a Send OTP button\"><figcaption>The number from your field is filled in.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>Verified, then the visitor submits your form<\/h3>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-site-attach-verified-hd.webp\" width=\"768\" height=\"546\" loading=\"lazy\" decoding=\"async\" alt=\"Popup over the sign-up form showing Mobile number verified and a Use a different number link\"><figcaption>After this, your Sign up button works.<\/figcaption><\/figure>\n<\/li>\n<\/ol>\n<h2>Mode 4: protect a whole form<\/h2>\n<p>Add <code>data-f2s-otp-protect<\/code> to your <code>form<\/code> tag. The widget appears inside the form, just above the submit button, and the form submits only after the number is verified. If the visitor clicks submit too early, the form stays put and the page scrolls to the widget.<\/p>\n<pre><code class=\"language-html\">&lt;script src=&quot;https:\/\/www.fast2sms.com\/widget\/otp-js?v=1.0.5&quot; defer&gt;&lt;\/script&gt;\n&lt;form action=&quot;\/your-signup&quot; method=&quot;post&quot; data-f2s-otp-protect=&quot;YOUR_WIDGET_KEY&quot;&gt;\n  &lt;input name=&quot;name&quot; data-f2s-forward placeholder=&quot;Your name&quot;&gt;\n  &lt;input name=&quot;email&quot; type=&quot;email&quot; data-f2s-forward placeholder=&quot;Email&quot;&gt;\n  &lt;button type=&quot;submit&quot;&gt;Sign up&lt;\/button&gt;\n&lt;\/form&gt;<\/code><\/pre>\n<p>What your form handler receives:<\/p>\n<ul>\n<li>Your normal fields, plus a hidden <code>f2s_token<\/code> field that the widget adds.<\/li>\n<li>Not the mobile number. The number is typed inside the widget frame, so it is not posted with your form. Get the full verified number on your server by checking <code>f2s_token<\/code>, or from the webhook.<\/li>\n<li>Fields marked <code>data-f2s-forward<\/code> are also sent to your webhook together with the verified number (up to 20 fields; password and file fields are never sent).<\/li>\n<\/ul>\n<p>Server code for the token check and the webhook is in <a href=\"https:\/\/www.fast2sms.com\/help\/otp-widget-verify-token-webhook\/\">OTP widget webhook and f2s_token check<\/a>.<\/p>\n<ol class=\"f2s-steps\">\n<li>\n<h3>Copy the Form code<\/h3>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-install-form-hd-1-scaled.webp\" width=\"1440\" height=\"900\" loading=\"lazy\" decoding=\"async\" alt=\"Install tab, Form sub-tab: Your form submits only after the number is verified, with a form example using data-f2s-otp-protect and data-f2s-forward on the name and email inputs\"><figcaption>Install, Form: one attribute on the form tag.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>The widget sits inside your form<\/h3>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-site-form-hd.webp\" width=\"768\" height=\"669\" loading=\"lazy\" decoding=\"async\" alt=\"Sample Sign up form with Your name and Email filled in, the OTP widget with a Mobile number field and Send OTP button, and a Sign up button below\"><figcaption>The widget appears above your submit button.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>After verification the form can be submitted<\/h3>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-site-form-verified-hd-1.webp\" width=\"768\" height=\"598\" loading=\"lazy\" decoding=\"async\" alt=\"The same sign-up form with the widget showing Mobile number verified and a Use a different number link above the Sign up button\"><figcaption>Verified: Sign up now submits with f2s_token.<\/figcaption><\/figure>\n<\/li>\n<\/ol>\n<aside class=\"f2s-cta\" aria-label=\"Get started with Fast2SMS\"><div class=\"f2s-cta__copy\"><strong class=\"f2s-cta__title\">Protect your forms with OTP<\/strong><p>Stop fake sign-ups and COD orders with a verified mobile number. The widget is free.<\/p><\/div><div class=\"f2s-cta__actions\"><a class=\"f2s-cta__btn f2s-cta__btn--primary\" href=\"https:\/\/www.fast2sms.com\/\"><span>Sign up free<\/span> <span class=\"f2sh-btn__arrow\" aria-hidden=\"true\">&rarr;<\/span><\/a><a class=\"f2s-cta__btn f2s-cta__btn--ghost\" href=\"https:\/\/www.fast2sms.com\/meet\/\" target=\"_blank\" rel=\"noopener\">Book a free meeting<\/a><\/div><\/aside>\n<h2>JavaScript events: f2s:sent, f2s:verified, f2s:error, f2s:reset<\/h2>\n<p>The widget fires four events on its element. They bubble, so you can listen on <code>document<\/code>. Each one carries details in <code>event.detail<\/code>:<\/p>\n<div class=\"f2s-facts\">\n<table>\n<thead>\n<tr>\n<th>Event<\/th>\n<th>When<\/th>\n<th>event.detail<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>f2s:sent<\/code><\/td>\n<td>A code was sent or resent<\/td>\n<td><code>masked<\/code> (like 98xxxxxx10), <code>resend<\/code> (true for a resend)<\/td>\n<\/tr>\n<tr>\n<td><code>f2s:verified<\/code><\/td>\n<td>The code was correct<\/td>\n<td><code>token<\/code>, <code>masked<\/code>, <code>expiresIn<\/code> (seconds the token stays valid)<\/td>\n<\/tr>\n<tr>\n<td><code>f2s:error<\/code><\/td>\n<td>Something stopped the flow<\/td>\n<td><code>reason<\/code>, for example <code>not_verified<\/code> (submit before verifying) or <code>number_mismatch<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>f2s:reset<\/code><\/td>\n<td>The visitor changed the number, or the token ran out<\/td>\n<td><code>wasVerified<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>A small example that turns an order button on only after verification:<\/p>\n<pre><code class=\"language-html\">&lt;script&gt;\n  \/\/ the events bubble, so one listener on document hears every widget on the page\n  document.addEventListener('f2s:verified', function (e) {\n    document.getElementById('place-order').disabled = false;\n    document.getElementById('otp-token').value = e.detail.token; \/\/ check it on your server\n  });\n  document.addEventListener('f2s:reset', function () {\n    document.getElementById('place-order').disabled = true;\n  });\n  document.addEventListener('f2s:error', function (e) {\n    console.log('OTP widget:', e.detail.reason);\n  });\n&lt;\/script&gt;<\/code><\/pre>\n<p>Use events to change your page, not as proof. Anyone can fire a fake event from the browser console. Before you save an order or an account, send the token to your server and check it there.<\/p>\n<h2>Which mode should you use?<\/h2>\n<ul>\n<li><strong>Widget<\/strong>: a page that is only about verifying, like a mobile login. See <a href=\"https:\/\/www.fast2sms.com\/help\/login-otp-flow\/\">how a login OTP flow works<\/a>.<\/li>\n<li><strong>Popup<\/strong>: one button, such as cash on delivery confirmation. See <a href=\"https:\/\/www.fast2sms.com\/help\/cod-order-confirmation-otp\/\">COD order confirmation with OTP<\/a>.<\/li>\n<li><strong>Mobile field<\/strong>: an existing form where you want to keep your own phone field.<\/li>\n<li><strong>Form<\/strong>: a new or simple form where you are happy with the widget&#8217;s own field. See <a href=\"https:\/\/www.fast2sms.com\/help\/otp-verification-signup-form\/\">OTP verification on a sign-up form<\/a>.<\/li>\n<\/ul>\n<p>The script works on plain HTML and in website builders that let you add your own code. See the guides for <a href=\"https:\/\/www.fast2sms.com\/help\/add-otp-verification-wordpress-without-plugin\/\">WordPress<\/a>, <a href=\"https:\/\/www.fast2sms.com\/help\/shopify-otp-verification-widget\/\">Shopify<\/a> and <a href=\"https:\/\/www.fast2sms.com\/help\/add-otp-verification-wix-webflow-blogger\/\">Wix, Webflow and Blogger<\/a>. After pasting, check the result with the <strong>Test<\/strong> tab and on the live page.<\/p>\n<h2>Common problems and fixes<\/h2>\n<div class=\"f2s-facts\">\n<table>\n<thead>\n<tr>\n<th>Problem<\/th>\n<th>Fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Clicking the button does nothing<\/td>\n<td>The script line is missing on this page, or the widget key in the attribute is wrong. Copy both lines again from <strong>Install<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>The popup says &#8220;Mobile verification is not available on this page right now.&#8221;<\/td>\n<td>Add this website&#8217;s address to <strong>Websites<\/strong> in Setup and check that <strong>Widget on<\/strong> is on.<\/td>\n<\/tr>\n<tr>\n<td>The form submits but your server has no number<\/td>\n<td>That is by design. Check <code>f2s_token<\/code> on your server to get the number.<\/td>\n<\/tr>\n<tr>\n<td>&#8220;Verified&#8221; disappears after editing the field<\/td>\n<td>Also by design: a changed number must be verified again.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<section class=\"f2s-faq\">\n<h2>Frequently asked questions<\/h2>\n<h3>How do I open an OTP popup when someone clicks my button?<\/h3>\n<p>Load the widget script once and add <code>data-f2s-otp-popup=\"YOUR_WIDGET_KEY\"<\/code> to your button. Copy both from <strong>Install<\/strong> &gt; <strong>Popup<\/strong>.<\/p>\n<h3>Can I change where the OTP popup appears?<\/h3>\n<p>Yes. Set <code>data-f2s-position<\/code> to center, top, bottom, left, right, top-left, top-right, bottom-left or bottom-right.<\/p>\n<h3>Can I keep my own mobile number field?<\/h3>\n<p>Yes. Use the <strong>Mobile field<\/strong> mode. A Verify button appears next to your field and the number is filled into the popup.<\/p>\n<h3>Will my form submit if the number is not verified?<\/h3>\n<p>No. In Mobile field and Form mode the form waits until the number is verified, and the widget fires <code>f2s:error<\/code> with <code>not_verified<\/code>.<\/p>\n<h3>How do I get the verified mobile number in my form handler?<\/h3>\n<p>Read the hidden <code>f2s_token<\/code> field and check it with the verify-token API. The answer has the full number.<\/p>\n<h3>Can I use two modes on the same page?<\/h3>\n<p>Yes. Load the script once and add the attributes you need, for example a popup button in the header and a protected form lower down.<\/p>\n<\/section>\n<aside class=\"f2s-cta\" aria-label=\"Get started with Fast2SMS\"><div class=\"f2s-cta__copy\"><strong class=\"f2s-cta__title\">Try the OTP widget on your site<\/strong><p>Sign up free, make a widget and copy the popup, mobile field or form code.<\/p><\/div><div class=\"f2s-cta__actions\"><a class=\"f2s-cta__btn f2s-cta__btn--primary\" href=\"https:\/\/www.fast2sms.com\/\"><span>Sign up free<\/span> <span class=\"f2sh-btn__arrow\" aria-hidden=\"true\">&rarr;<\/span><\/a><a class=\"f2s-cta__btn f2s-cta__btn--ghost\" href=\"https:\/\/www.fast2sms.com\/meet\/\" target=\"_blank\" rel=\"noopener\">Book a free meeting<\/a><\/div><\/aside>\n<h2>Related guides<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.fast2sms.com\/help\/free-otp-widget-for-website\/\">Free OTP widget for your website<\/a><\/li>\n<li><a href=\"https:\/\/www.fast2sms.com\/help\/otp-widget-verify-token-webhook\/\">OTP widget webhook and f2s_token check<\/a><\/li>\n<li><a href=\"https:\/\/www.fast2sms.com\/help\/whatsapp-otp-widget-for-website\/\">WhatsApp OTP widget for your website<\/a><\/li>\n<li><a href=\"https:\/\/www.fast2sms.com\/help\/otp-autofill-android-ios-sms-retriever\/\">OTP autofill on Android and iPhone<\/a><\/li>\n<li><a href=\"https:\/\/www.fast2sms.com\/otp-sms\">Smart OTP: SMS and WhatsApp OTP<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>To show an OTP popup on button click, add data-f2s-otp-popup=&#8221;YOUR_WIDGET_KEY&#8221; to your own button and load the Fast2SMS widget script once on the page. When a visitor clicks the button, the free OTP widget opens in a popup, they verify their mobile number, and the popup closes. This page covers all four install modes of [&hellip;]<\/p>\n","protected":false},"featured_media":20911,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[],"class_list":["post-20932","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-api","category-otp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>OTP Popup on Button Click for Websites | Fast2SMS<\/title>\n<meta name=\"description\" content=\"Open an OTP popup on button click, add a Verify button to your own mobile field or protect a whole form with the free Fast2SMS OTP widget. Code and events.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"OTP Popup on Button Click for Websites | Fast2SMS\" \/>\n<meta property=\"og:description\" content=\"Open an OTP popup on button click, add a Verify button to your own mobile field or protect a whole form with the free Fast2SMS OTP widget. Code and events.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/\" \/>\n<meta property=\"og:site_name\" content=\"Fast2SMS\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Fast2SMS\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-20T17:58:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-install-simple-hd-1-scaled.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fast2sms\" \/>\n<meta name=\"twitter:site\" content=\"@fast2sms\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-popup-button-mobile-field\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-popup-button-mobile-field\\\/\"},\"author\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\"},\"headline\":\"OTP popup on button click, Verify button on your mobile field and form protect (OTP widget)\",\"datePublished\":\"2026-11-20T17:58:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-popup-button-mobile-field\\\/\"},\"wordCount\":1708,\"publisher\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-popup-button-mobile-field\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/otpw-install-simple-hd-1-scaled.webp\",\"articleSection\":[\"API\",\"OTP\"],\"inLanguage\":\"en-IN\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-popup-button-mobile-field\\\/\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-popup-button-mobile-field\\\/\",\"name\":\"OTP Popup on Button Click for Websites | Fast2SMS\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-popup-button-mobile-field\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-popup-button-mobile-field\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/otpw-install-simple-hd-1-scaled.webp\",\"datePublished\":\"2026-11-20T17:58:37+00:00\",\"description\":\"Open an OTP popup on button click, add a Verify button to your own mobile field or protect a whole form with the free Fast2SMS OTP widget. Code and events.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-popup-button-mobile-field\\\/#breadcrumb\"},\"inLanguage\":\"en-IN\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-popup-button-mobile-field\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-IN\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-popup-button-mobile-field\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/otpw-install-simple-hd-1-scaled.webp\",\"contentUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/otpw-install-simple-hd-1-scaled.webp\",\"width\":2560,\"height\":1600,\"caption\":\"Install tab, Widget sub-tab: Paste this on your website where the widget should show, with a Copy button and the script and div code\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-popup-button-mobile-field\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"API\",\"item\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/api\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"OTP popup on button click, Verify button on your mobile field and form protect (OTP widget)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/#website\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/\",\"name\":\"Fast2SMS\",\"description\":\"Help\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\"},\"inLanguage\":\"en-IN\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\",\"name\":\"Fast2SMS\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#logo\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/Fast2SMS.png\",\"contentUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/Fast2SMS.png\",\"caption\":\"Fast2SMS\"},\"image\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#logo\"},\"email\":\"support@fast2sms.com\",\"telephone\":\"+91-6262778822\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Fast2SMS\",\"https:\\\/\\\/www.instagram.com\\\/fast2sms\",\"https:\\\/\\\/x.com\\\/fast2sms\",\"https:\\\/\\\/www.youtube.com\\\/Fast2SMSofficial\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/fast2sms\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"OTP Popup on Button Click for Websites | Fast2SMS","description":"Open an OTP popup on button click, add a Verify button to your own mobile field or protect a whole form with the free Fast2SMS OTP widget. Code and events.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/","og_locale":"en_US","og_type":"article","og_title":"OTP Popup on Button Click for Websites | Fast2SMS","og_description":"Open an OTP popup on button click, add a Verify button to your own mobile field or protect a whole form with the free Fast2SMS OTP widget. Code and events.","og_url":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/","og_site_name":"Fast2SMS","article_publisher":"https:\/\/www.facebook.com\/Fast2SMS\/","article_published_time":"2026-11-20T17:58:37+00:00","og_image":[{"width":2560,"height":1600,"url":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-install-simple-hd-1-scaled.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_creator":"@fast2sms","twitter_site":"@fast2sms","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/#article","isPartOf":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/"},"author":{"@id":"https:\/\/www.fast2sms.com\/#organization"},"headline":"OTP popup on button click, Verify button on your mobile field and form protect (OTP widget)","datePublished":"2026-11-20T17:58:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/"},"wordCount":1708,"publisher":{"@id":"https:\/\/www.fast2sms.com\/#organization"},"image":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/#primaryimage"},"thumbnailUrl":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-install-simple-hd-1-scaled.webp","articleSection":["API","OTP"],"inLanguage":"en-IN"},{"@type":"WebPage","@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/","url":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/","name":"OTP Popup on Button Click for Websites | Fast2SMS","isPartOf":{"@id":"https:\/\/www.fast2sms.com\/help\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/#primaryimage"},"image":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/#primaryimage"},"thumbnailUrl":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-install-simple-hd-1-scaled.webp","datePublished":"2026-11-20T17:58:37+00:00","description":"Open an OTP popup on button click, add a Verify button to your own mobile field or protect a whole form with the free Fast2SMS OTP widget. Code and events.","breadcrumb":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/#breadcrumb"},"inLanguage":"en-IN","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/"]}]},{"@type":"ImageObject","inLanguage":"en-IN","@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/#primaryimage","url":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-install-simple-hd-1-scaled.webp","contentUrl":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otpw-install-simple-hd-1-scaled.webp","width":2560,"height":1600,"caption":"Install tab, Widget sub-tab: Paste this on your website where the widget should show, with a Copy button and the script and div code"},{"@type":"BreadcrumbList","@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-popup-button-mobile-field\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.fast2sms.com\/help\/"},{"@type":"ListItem","position":2,"name":"API","item":"https:\/\/www.fast2sms.com\/help\/api\/"},{"@type":"ListItem","position":3,"name":"OTP popup on button click, Verify button on your mobile field and form protect (OTP widget)"}]},{"@type":"WebSite","@id":"https:\/\/www.fast2sms.com\/help\/#website","url":"https:\/\/www.fast2sms.com\/help\/","name":"Fast2SMS","description":"Help","publisher":{"@id":"https:\/\/www.fast2sms.com\/#organization"},"inLanguage":"en-IN"},{"@type":"Organization","@id":"https:\/\/www.fast2sms.com\/#organization","name":"Fast2SMS","url":"https:\/\/www.fast2sms.com\/","logo":{"@type":"ImageObject","@id":"https:\/\/www.fast2sms.com\/#logo","url":"https:\/\/www.fast2sms.com\/Fast2SMS.png","contentUrl":"https:\/\/www.fast2sms.com\/Fast2SMS.png","caption":"Fast2SMS"},"image":{"@id":"https:\/\/www.fast2sms.com\/#logo"},"email":"support@fast2sms.com","telephone":"+91-6262778822","sameAs":["https:\/\/www.facebook.com\/Fast2SMS","https:\/\/www.instagram.com\/fast2sms","https:\/\/x.com\/fast2sms","https:\/\/www.youtube.com\/Fast2SMSofficial","https:\/\/www.linkedin.com\/company\/fast2sms"]}]}},"_links":{"self":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/posts\/20932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/comments?post=20932"}],"version-history":[{"count":0,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/posts\/20932\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/media\/20911"}],"wp:attachment":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/media?parent=20932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/categories?post=20932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/tags?post=20932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}