├── README.md ├── html-form-with-recaptcha.html ├── html-form.html ├── react-form-with-recaptcha.jsx ├── react-form.jsx └── vue-form.vue /README.md: -------------------------------------------------------------------------------- 1 | # FormBold examples for different frameworks and libraries 2 | 3 | FormBold provides free form API that works with all frameworks, libraries, and platforms. This repository contains ready to use code examples and usage of FormBold API with various tech stacks such as - React, HTML, Vue, and Gatsby, etc. 4 | -------------------------------------------------------------------------------- /html-form-with-recaptcha.html: -------------------------------------------------------------------------------- 1 | // Loading reCAPTCHA script 2 | 3 | 4 |
17 | -------------------------------------------------------------------------------- /html-form.html: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /react-form-with-recaptcha.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | import axios from "axios"; 3 | // Install dependency - npm install react-google-recaptcha 4 | import ReCAPTCHA from "react-google-recaptcha"; 5 | 6 | export default function Forms() { 7 | const recaptchaRef = React.createRef(); 8 | 9 | // Input Change Handling 10 | const [inputs, setInputs] = useState({ 11 | email: "", 12 | subject: "", 13 | message: "", 14 | }); 15 | const handleOnChange = (event) => { 16 | event.persist(); 17 | setInputs((prev) => ({ 18 | ...prev, 19 | [event.target.id]: event.target.value, 20 | })); 21 | }; 22 | 23 | // Server State Handling 24 | 25 | const handleOnSubmit = (event) => { 26 | event.preventDefault(); 27 | 28 | axios({ 29 | method: "POST", 30 | url: "https://formbold.com/s/FORM_ID", 31 | data: {...inputs, 'g-recaptcha-response': recaptchaRef.current.getValue()}, 32 | }) 33 | .then((r) => { 34 | console.log("hello"); 35 | }) 36 | .catch((r) => { 37 | console.log("error"); 38 | }); 39 | }; 40 | 41 | return ( 42 | 73 | ); 74 | } 75 | -------------------------------------------------------------------------------- /react-form.jsx: -------------------------------------------------------------------------------- 1 | import { useForm } from "formbold-react"; 2 | 3 | function Form() { 4 | const [state, handleSubmit] = useForm("Form_ID"); 5 | 6 | if (state.succeeded) { 7 | return