Skip to content
- Tutorials
- Python Tutorial
- Taking Input in Python
- Python Operators
- Python Data Types
- Python Loops and Control Flow
- Python Functions
- Python OOPS Concept
- Python Data Structures
- Python Exception Handling
- Python File Handling
- Python Exercises
- Java
- Java Programming Language
- Java Collections
- Java 8 Tutorial
- Java Programs
- Java Interview Questions
- Java Exercises
- Java Quiz
- Java Projects
- Advance Java
- Programming Languages
- System Design
- Interview Corner
- Computer Science Subjects
- DevOps
- Linux
- Software Testing
- Databases
- Android
- Excel
- Mathematics
- Python Tutorial
- DSA
- Data Structures
- Algorithms
- Analysis of Algorithms
- Searching Algorithms
- Sorting Algorithms
- Greedy Algorithms
- Dynamic Programming
- Graph Algorithms
- Pattern Searching
- Recursion
- Backtracking
- Divide and Conquer
- Mathematical Algorithms
- Geometric Algorithms
- Bitwise Algorithms
- Randomized Algorithms
- Branch and Bound
- Algorithms Tutorial
- DSA Tutorial
- Practice
- All DSA Problems
- Problem of the Day
- Company Wise Coding Practice
- GfG SDE Sheet
- Practice Problems Difficulty Wise
- Language Wise Coding Practice
- Curated DSA Lists
- Competitive Programming
- Company Wise SDE Sheets
- DSA Cheat Sheets
- Top Interview Questions
- Puzzles
- Data Science
- Web Tech
- Courses
-
Last Updated : 21 Dec, 2022
Summarize
Comments
Improve
Recommended Problem
Show Topics
Topics:
Easy
57.58%
10.3K
Given string str, the task is to check whether it is a valid CVV (Card Verification Value) number or not by using Regular Expression.
The valid CVV (Card Verification Value) number must satisfy the following conditions:- It should have 3 or 4 digits.
- It should have a digit between 0-9.
- It should not have any alphabet or special characters.
Examples:
Input: str = “561”
Output: true
Explanation:
The given string satisfies all the above mentioned conditions. Therefore, it is a valid CVV (Card Verification Value) number.Input: str = “50614”
Output: false
Explanation:
The given string has five-digit. Therefore, it is not a valid CVV (Card Verification Value) number.Input: str = “5a#1”
Output: false
Explanation: The given string has alphabets and special characters. Therefore, it is not a valid CVV (Card Verification Value) number.Approach: The idea is to use Regular Expression to solve this problem. The following steps can be followed to compute the answer.
- Get the String.
- Create a regular expression to check the valid CVV (Card Verification Value) number as mentioned below:
regex = "^[0-9]{3, 4}$";
- Where:
- ^ represents the starting of the string.
- [0-9] represents the digit between 0-9.
- {3, 4} represents the string that has 3 or 4 digits.
- $ represents the ending of the string.
- Match the given string with the regular expression. In Java, this can be done by using Pattern.matcher().
- Return true if the string matches with the given regular expression, else return false.
Below is the implementation of the above approach:
C++
// C++ program to validate the
// CVV (Card Verification Value) number
// using Regular Expression
#include <iostream>
#include <regex>
using
namespace
std;
// Function to validate the CVV
// (Card Verification Value) number
bool
isValidCVVNumber(string str)
{
// Regex to check valid CVV
// (Card Verification Value) number
const
regex pattern(
"^[0-9]{3,4}$"
);
// If the CVV (Card Verification Value)
// number is empty return false
if
(str.empty())
{
return
false
;
}
// Return true if the CVV
// (Card Verification Value) number
// matched the ReGex
if
(regex_match(str, pattern))
{
return
true
;
}
else
{
return
false
;
}
}
// Driver Code
int
main()
{
// Test Case 1:
string str1 =
"561"
;
cout << isValidCVVNumber(str1) << endl;
// Test Case 2:
string str2 =
"5061"
;
cout << isValidCVVNumber(str2) << endl;
// Test Case 3:
string str3 =
"50614"
;
cout << isValidCVVNumber(str3) << endl;
// Test Case 4:
string str4 =
"5a#1"
;
cout << isValidCVVNumber(str4) << endl;
return
0;
}
See AlsoCardholder Verification Methods: Concepts, Implementations, and ImpactsWhat is CVV on Debit Card? - Complete Information// This code is contributed by yuvraj_chandra
Java
// Java program to validate
// CVV (Card Verification Value)
// number using regex.
import
java.util.regex.*;
class
GFG {
// Function to validate
// CVV (Card Verification Value) number.
// using regular expression.
public
static
boolean
isValidCVVNumber(String str)
{
// Regex to check valid CVV number.
String regex =
"^[0-9]{3,4}$"
;
// Compile the ReGex
Pattern p = Pattern.compile(regex);
// If the string is empty
// return false
if
(str ==
null
)
{
return
false
;
}
// Find match between given string
// and regular expression
// using Pattern.matcher()
Matcher m = p.matcher(str);
// Return if the string
// matched the ReGex
return
m.matches();
}
// Driver code
public
static
void
main(String args[])
{
// Test Case 1:
String str1 =
"561"
;
System.out.println(isValidCVVNumber(str1));
// Test Case 2:
String str2 =
"5061"
;
System.out.println(isValidCVVNumber(str2));
// Test Case 3:
String str3 =
"50614"
;
System.out.println(isValidCVVNumber(str3));
// Test Case 4:
String str4 =
"5a#1"
;
System.out.println(isValidCVVNumber(str4));
}
}
Python3
# Python3 program to validate
# CVV (Card Verification Value)
# number using regex.
import
re
# Function to validate
# CVV (Card Verification Value) number.
# using regular expression.
def
isValidCVVNumber(
str
):
# Regex to check valid
# CVV number.
regex
=
"^[0-9]{3,4}$"
# Compile the ReGex
p
=
re.
compile
(regex)
# If the string is empty
# return false
if
(
str
=
=
None
):
return
False
# Return if the string
# matched the ReGex
if
(re.search(p,
str
)):
return
True
else
:
return
False
# Driver code
# Test Case 1:
str1
=
"561"
print
(isValidCVVNumber(str1))
# Test Case 2:
str2
=
"5061"
print
(isValidCVVNumber(str2))
# Test Case 3:
str3
=
"50614"
print
(isValidCVVNumber(str3))
# Test Case 4:
str4
=
"5a#1"
print
(isValidCVVNumber(str4))
# This code is contributed by avanitrachhadiya2155
C#
// C# program to validate the
// CVV (Card Verification Value) number
//using Regular Expressions
using
System;
using
System.Text.RegularExpressions;
class
GFG
{
// Main Method
static
void
Main(
string
[] args)
{
// Input strings to Match
// CVV (Card Verification Value) number
string
[] str={
"561"
,
"5061"
,
"50614"
,
"5a#1"
};
foreach
(
string
s
in
str) {
Console.WriteLine( isValidCVVNumber(s) ?
"true"
:
"false"
);
}
Console.ReadKey(); }
// method containing the regex
public
static
bool
isValidCVVNumber(
string
str)
{
string
strRegex =
@"^[0-9]{3,4}$"
;
Regex re =
new
Regex(strRegex);
if
(re.IsMatch(str))
return
(
true
);
else
return
(
false
);
}
}
// This code is contributed by Rahul Chauhan
Javascript
// Javascript program to validate
// CVV Number using Regular Expression
// Function to validate the
// CVV_Number
function
isValid_CVV_Number(CVV_Number) {
// Regex to check valid
// CVV_Number
let regex =
new
RegExp(/^[0-9]{3,4}$/);
// if CVV_Number
// is empty return false
if
(CVV_Number ==
null
) {
return
"false"
;
}
// Return true if the CVV_Number
// matched the ReGex
if
(regex.test(CVV_Number) ==
true
) {
return
"true"
;
}
else
{
return
"false"
;
}
}
// Driver Code
// Test Case 1:
let str1 =
"561"
;
console.log(isValid_CVV_Number(str1));
// Test Case 2:
let str2 =
"5061"
;
console.log(isValid_CVV_Number(str2));
// Test Case 3:
let str3 =
"50614"
;
console.log(isValid_CVV_Number(str3));
// Test Case 4:
let str4 =
"5a#1"
;
console.log(isValid_CVV_Number(str4));
// Test Case 5:
let str5 =
"12071998"
;
console.log(isValid_CVV_Number(str5));
// Test Case 6:
let str6 =
"RAH12071998"
;
console.log(isValid_CVV_Number(str6));
// This code is contributed by Rahul Chauhan
Output
truetruefalsefalse
Time Complexity: O(N) for each testcase, where N is the length of the given string.
Auxiliary Space: O(1)
Please Login to comment...
Similar Reads
How to validate Indian driving license number using Regular Expression
Given string str, the task is to check whether the given string is a valid Indian driving license number or not by using Regular Expression.The valid Indian driving license number must satisfy the following conditions: It should be 16 characters long (including space or hyphen (-)).The driving license number can be entered in any of the following f
7 min read
How to validate SSN (Social Security Number) using Regular Expression
Given string str, the task is to check whether the given string is valid SSN (Social Security Number) or not by using Regular Expression. The valid SSN (Social Security Number) must satisfy the following conditions: It should have 9 digits.It should be divided into 3 parts by hyphen (-).The first part should have 3 digits and should not be 000, 666
6 min read
Validate Corporate Identification Number (CIN) using Regular Expression
Given some Corporate Identification Number, the task is to check if they are valid or not using regular expressions. Rules for the valid CIN are: CIN is a 21 digits alpha-numeric code.It starts with either alphabet letter U or L.Next five characters are reserved for digits (0-9).Next two places are occupied by alphabet letters(A-Z-a-z).Next four pl
6 min read
How to validate PAN Card number using Regular Expression
Given string str of alphanumeric characters, the task is to check whether the string is a valid PAN (Permanent Account Number) Card number or not by using Regular Expression.The valid PAN Card number must satisfy the following conditions: It should be ten characters long.The first five characters should be any upper case alphabets.The next four-cha
6 min read
How to validate GST (Goods and Services Tax) number using Regular Expression
Given string str, the task is to check whether the given string is a valid GST (Goods and Services Tax) number or not using Regular Expression. The valid GST (Goods and Services Tax) number must satisfy the following conditions: It should be 15 characters long.The first 2 characters should be a number.The next 10 characters should be the PAN number
6 min read
How to validate MasterCard number using Regular Expression
Given string str, the task is to check whether the given string is a valid Master Card number or not by using Regular Expression. The valid Master Card number must satisfy the following conditions. It should be 16 digits long.It should start with either two digits numbers may range from 51 to 55 or four digits numbers may range from 2221 to 2720.In
7 min read
How to validate Visa Card number using Regular Expression
Given a string str, the task is to check whether the given string is a valid Visa Card number or not by using Regular Expression. The valid Visa Card number must satisfy the following conditions: It should be 13 or 16 digits long, new cards have 16 digits and old cards have 13 digits.It should start with 4.If the cards have 13 digits the next twelv
6 min read
How to validate Indian Passport number using Regular Expression
Given a string str of alphanumeric characters, the task is to check whether the given string is a valid passport number or not by using Regular Expression. A valid passport number in India must satisfy the following conditions: It should be eight characters long.The first character should be an uppercase alphabet.The next two characters should be a
5 min read
How to validate MAC address using Regular Expression
Given string str, the task is to check whether the given string is a valid MAC address or not by using Regular Expression. A valid MAC address must satisfy the following conditions: It must contain 12 hexadecimal digits.One way to represent them is to form six pairs of the characters separated with a hyphen (-) or colon(:). For example, 01-23-45-67
6 min read
How to validate time in 24-hour format using Regular Expression
Given a string str, the task is to check whether the string is valid time in 24-hour format or not by using Regular Expression. The valid time in the 24-hour format must satisfy the following conditions. It should start from 0-23 or 00-23.It should be followed by a ':'(colon).It should be followed by two digits from 00 to 59.It should not end with
6 min read
How to validate pin code of India using Regular Expression
Given a string of positive number ranging from 0 to 9, the task is to check whether the number is valid pin code or not by using a Regular Expression. The valid pin code of India must satisfy the following conditions. It can be only six digits.It should not start with zero.First digit of the pin code must be from 1 to 9.Next five digits of the pin
6 min read
How to validate Hexadecimal Color Code using Regular Expression
Given string str, the task is to check whether the string is valid hexadecimal colour code or not by using Regular Expression. The valid hexadecimal color code must satisfy the following conditions. It should start from '#' symbol.It should be followed by the letters from a-f, A-F and/or digits from 0-9.The length of the hexadecimal color code shou
6 min read
How to validate image file extension using Regular Expression
Given string str, the task is to check whether the given string is a valid image file extension or not by using Regular Expression. The valid image file extension must specify the following conditions: It should start with a string of at least one character.It should not have any white space.It should be followed by a dot(.).It should be end with a
5 min read
How to validate HTML tag using Regular Expression
Given string str, the task is to check whether it is a valid HTML tag or not by using Regular Expression.The valid HTML tag must satisfy the following conditions: It should start with an opening tag (<).It should be followed by a double quotes string or single quotes string.It should not allow one double quotes string, one single quotes string o
6 min read
How to validate IFSC Code using Regular Expression
Given string str, the task is to check whether the given string is a valid IFSC (Indian Financial System) Code or not by using Regular Expression. The valid IFSC (Indian Financial System) Code must satisfy the following conditions: It should be 11 characters long.The first four characters should be upper case alphabets.The fifth character should be
8 min read
How to validate GUID (Globally Unique Identifier) using Regular Expression
Given string str, the task is to check whether the given string is a valid GUID (Globally Unique Identifier) or not by using Regular Expression.The valid GUID (Globally Unique Identifier) must specify the following conditions: It should be a 128-bit number.It should be 36 characters (32 hexadecimal characters and 4 hyphens) long.It should be displa
6 min read
Validate week days using Regular Expression
Given some Weekdays, the task is to check if they are valid or not using regular expressions. Rules for the valid Weekdays : It should contain specific only words as a string. They are mentioned below:Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday.Mon, Tues, Wed, Thurs, Fri, Sat, Sun. Mon., Tues., Wed., Thurs., Fri., Sat., Sun.
5 min read
Validate localhost API request processed by POSTMAN using Regular Expression
Given some Postman APIs, the task is to check if they are valid or not using regular expressions. Rules for the valid API: It is an alphanumeric String, a combination of alphabets ( 'a' to 'z') and digits (0 to 9).It should always start with HTTP and must contain some special symbols (':', '/')It should not contain any whitespaces. Examples: Input:
6 min read
How to Validate MICR Code using Regular Expression?
MICR stands for Magnetic Ink Character Recognition. This technology provides transaction security, ensuring the correctness of bank cheques. MICR code makes cheque processing faster and safer. MICR Technology reduces cheque-related fraudulent activities. Structure of a Magnetic Ink Character Recognition(MICR) Code: It is a 9-digit code.It should be
6 min read
Validate GIT Repository using Regular Expression
GIT stands for GLOBAL INFORMATION TRACKER.Given some Git repositories, the task is to check if they are valid or not using regular expressions. Rules for the valid Git Repository are: It is an alphanumeric string containing uppercase Alphabet letters(A-Z) and digits(0-9).It should not contain any white spaces.It can contain some special symbols lik
5 min read
Validate Phone Numbers ( with Country Code extension) using Regular Expression
Given some Phone Numbers, the task is to check if they are valid or not using regular expressions. Rules for the valid phone numbers are: The numbers should start with a plus sign ( + )It should be followed by Country code and National number.It may contain white spaces or a hyphen ( - ).the length of phone numbers may vary from 7 digits to 15 digi
5 min read
How to validate time in 12-hour format using Regular Expression
Given a string str, the task is to check whether the string is valid time in 12-hour format or not by using Regular Expression. The valid time in a 12-hour format must satisfy the following conditions: It should start from 1, 2, ... 9 or 10, 11, 12.It should be followed by a colon(:).It should be followed by two digits between 00 to 59.It should on
5 min read
Validate LEI(Legal Entity Identifier) using Regular Expression
Given some Legal Entity Identifier, the task is to check whether they are valid using regular expressions. Rules for the valid LEI are: LEI code length is comprised of a 20-digit alphanumeric code.The first four characters are digits. Next two places are reserved for digit Zero.Next 12 characters are reserved for an alphanumeric code containing dig
6 min read
How to validate a domain name using Regular Expression
Given string str, the task is to check whether the given string is a valid domain name or not by using Regular Expression.The valid domain name must satisfy the following conditions: The domain name should be a-z or A-Z or 0-9 and hyphen (-).The domain name should be between 1 and 63 characters long.The domain name should not start or end with a hy
6 min read
Regular Expression to Validate a Bitcoin Address
BITCOIN is a digital currency. During the digital currency transaction, a BTC address is required to verify the legality of a bitcoin wallet a Bitcoin address is a long set of alphanumeric characters that contains numbers and letters. A Bitcoin address indicates the source or destination of a Bitcoin payment. A Bitcoin wallet is a digital wallet th
6 min read
Regular Expressions to Validate Provident Fund(PF) Account Number
Given some PF(Provident Fund) Account Number, the task is to check if they are valid or not using regular expressions. Rules for the valid PF Account Number are : PF account number is alphanumeric String and forward slaces.First five characters are reserved for alphabet letters.Next 17 characters are reserved for digits(0-9).It allows only special
5 min read
Regular Expressions to validate Loan Account Number (LAN)
Given some Loan Account Number(LAN), the task is to check if they are valid or not using regular expressions. Rules for the valid Loan Account Number are: LAN is an alphanumeric string i.e., contains only digits (0-9) and uppercase alphabet characters.It does not allow whitespaces in it.It does not contain special characters.It starts with Uppercas
5 min read
Regular Expressions to Validate Account Office Reference Number
Given some Account Office Reference Number, the task is to check if they are valid or not using regular expressions. Rules for the valid Account Office Reference Number are: It is an alphanumeric string containing upper-case letters and digits.Accounts Office Reference Number is a unique, 13-character code.It starts with digits (0-9) and ends with
5 min read
How to validate an IP address using Regular Expressions in Java
Given an IP address, the task is to validate this IP address with the help of Regular Expressions.The IP address is a string in the form "A.B.C.D", where the value of A, B, C, and D may range from 0 to 255. Leading zeros are allowed. The length of A, B, C, or D can't be greater than 3.Examples: Input: str = "000.12.12.034" Output: True Input: str =
3 min read
How to validate a Username using Regular Expressions in Java
Given a string str which represents a username, the task is to validate this username with the help of Regular Expressions. A username is considered valid if all the following constraints are satisfied: The username consists of 6 to 30 characters inclusive. If the username consists of less than 6 or greater than 30 characters, then it is an invalid
3 min read
Article Tags :
Practice Tags :
Trending in News
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, check: true }), success:function(result) { jQuery.ajax({ url: writeApiUrl + 'suggestions/auth/' + `${post_id}/`, type: "GET", dataType: 'json', xhrFields: { withCredentials: true }, success: function (result) { $('.spinner-loading-overlay:eq(0)').remove(); var commentArray = result; if(commentArray === null || commentArray.length === 0) { // when no reason is availaible then user will redirected directly make the improvment. // call to api create-improvement-post $('body').append('
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.unlocked-status--improve-modal-content').css("display","none"); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); return; } var improvement_reason_html = ""; for(var comment of commentArray) { // loop creating improvement reason list markup var comment_id = comment['id']; var comment_text = comment['suggestion']; improvement_reason_html += `
${comment_text}
`; } $('.improvement-reasons_wrapper').html(improvement_reason_html); $('.improvement-bottom-btn').html("Create Improvement"); $('.improve-modal--improvement').hide(); $('.improvement-reason-modal').show(); }, error: function(e){ $('.spinner-loading-overlay:eq(0)').remove(); // stop loader when ajax failed; }, }); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); } else { if(loginData && !loginData.isLoggedIn) { $('.improve-modal--overlay').hide(); if ($('.header-main__wrapper').find('.header-main__signup.login-modal-btn').length) { $('.header-main__wrapper').find('.header-main__signup.login-modal-btn').click(); } return; } } }); $('.left-arrow-icon_wrapper').on('click',function(){ if($('.improve-modal--suggestion').is(":visible")) $('.improve-modal--suggestion').hide(); else{ $('.improvement-reason-modal').hide(); } $('.improve-modal--improvement').show(); }); function loadScript(src, callback) { var script = document.createElement('script'); script.src = src; script.onload = callback; document.head.appendChild(script); } function suggestionCall() { var suggest_val = $.trim($("#suggestion-section-textarea").val()); var array_String= suggest_val.split(" ") var gCaptchaToken = $("#g-recaptcha-response-suggestion-form").val(); var error_msg = false; if(suggest_val != "" && array_String.length >=4){ if(suggest_val.length <= 2000){ var payload = { "gfg_post_id" : `${post_id}`, "suggestion" : `
${suggest_val}
`, } if(!loginData || !loginData.isLoggedIn) // User is not logged in payload["g-recaptcha-token"] = gCaptchaToken jQuery.ajax({ type:'post', url: "https://apiwrite.geeksforgeeks.org/suggestions/auth/create/", xhrFields: { withCredentials: true }, crossDomain: true, contentType:'application/json', data: JSON.stringify(payload), success:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-section-textarea').val(""); jQuery('.suggest-bottom-btn').css("display","none"); // Update the modal content const modalSection = document.querySelector('.suggestion-modal-section'); modalSection.innerHTML = `
Thank You!
Your suggestions are valuable to us.
You can now also contribute to the GeeksforGeeks community by creating improvement and help your fellow geeks.
`; }, error:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Something went wrong."); jQuery('#suggestion-modal-alert').show(); error_msg = true; } }); } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Minimum 5 Words and Maximum Character limit is 2000."); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Enter atleast four words !"); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } if(error_msg){ setTimeout(() => { jQuery('#suggestion-section-textarea').focus(); jQuery('#suggestion-modal-alert').hide(); }, 3000); } } document.querySelector('.suggest-bottom-btn').addEventListener('click', function(){ jQuery('body').append('
'); jQuery('.spinner-loading-overlay').show(); if(loginData && loginData.isLoggedIn) { suggestionCall(); return; } // load the captcha script and set the token loadScript('https://www.google.com/recaptcha/api.js?render=6LdMFNUZAAAAAIuRtzg0piOT-qXCbDF-iQiUi9KY',[], function() { setGoogleRecaptcha(); }); }); $('.improvement-bottom-btn.create-improvement-btn').click(function() { //create improvement button is clicked $('body').append('
'); $('.spinner-loading-overlay').show(); // send this option via create-improvement-post api jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.improvement-reason-modal').hide(); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); });
Continue without supporting 😢