Method of splitting names based on jquery (pure JS version)_jquery
I have previously shared a jquery plug-in that automatically splits the name into the first and last name in the form using js after the user enters the name in the dom. Due to the needs of the project, a jquery plug-in is needed to automatically split the name on the client, but the split result does not need to be presented. method for users, so I wrote an independent method and posted it to share with everyone
$.extend({
splitName: function(fullname){
var hyphenated = ['Ouyang','Taishi','Duanmu','Shangguan','Sima', 'Dongfang','Dugu','Nangong','Wanqi','Wenren','Xiahou','Zhuge','Yuchi','Gongyang','Helian','Tantai',' Huangfu',
'Zongzheng', 'Puyang', 'Gongye', 'Tai Shu', 'Shentu', 'Gongsun', 'Murong', 'Zhongsun', 'Zhongli', 'Changsun', 'Yuwen','Chengchi','Situ','Xianyu','Sikong','Ruyan','Luqiu','Ziche','Qiguan',
'Sikou','Wuma ', 'Gongxi', 'Zhuansun', 'Rangsi', 'Gongliang', 'Qidiao', 'Lezheng', 'Zaifu', 'Guliang', 'Tuoba', 'Jiagu', 'Xuanyuan', 'Linghu', 'Duanqian', 'Baili', 'Huyan', 'Dongguo', 'Nanmen',
'Sheep's tongue', 'Weisheng', 'Gonghu', 'Gongyu', 'Gongyi', 'Liangqiu', 'Gongzhong', 'Gongshang', 'Gongmen', 'Gongshan', 'Gongjian', 'Zuoqiu', 'Gongbo', 'Ximen', 'Gongzu', 'Fifth', 'Gongcheng', 'Guanqiu', 'Gongxi',
'Nanrong', 'Dongli', 'Donggong', 'Zhongchang' ,'Zishu','Zisang','Jimo','Daxi','Chushi'];
var vLength = fullname.length;
var lastname = '', firstname = '';/ /The first is the surname, the last is the first name
if(vLength > 2){
var preTwoWords = fullname.substr(0, 2);//Get the first two words of the name to see if they are in the compound surname library
if($.inArray(preTwoWords, hyphenated) > -1){
lastname = preTwoWords;
firstname = fullname.substr(2);
}else{
lastname = fullname .substr(0, 1);
firstname = fullname.substr(1);
}
}else if(vLength == 2){//When the full name has only two characters, the previous one is Last name, the last name is the first name
lastname = fullname.substr(0, 1);
firstname = fullname.substr(1);
}else{
lastname = fullname;
}
return [lastname, firstname];
}
});

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Get started quickly: JSON array merging and splitting techniques in Java In modern software development, data format and transmission have become increasingly important. Among them, JSON (JavaScriptObjectNotation) is a commonly used data format, especially suitable for front-end and back-end interaction and data storage. In Java development, we often need to deal with JSON objects and JSON arrays. This article explains how to merge and split JSON arrays in Java, along with tips and examples for implementing these operations.

How to use PHPZipArchive to merge and split multiple compressed packages? Overview: During the development process, sometimes we need to merge multiple compressed packages into one, or split a compressed package into multiple ones. PHP provides the ZipArchive extension to easily complete these operations. This article will introduce how to use PHPZipArchive to merge and split multiple compressed packages. Merging multiple archives First, we need to create a new archive and open it. Then, the loop traversal needs to be

When the HTML page jumps to the PHP page, if the name field cannot be empty, the corresponding form verification function needs to be added to the HTML page. The following is a simple sample code to enable a warning message to pop up when the form is submitted when the user does not fill in the name: HTML page code (index.html): Name field validation example&l

The user has to enter the number of names and the names need to be sorted alphabetically using the strcpy() function. An array (or collection of characters) of characters is called a string. Declaration The following is the declaration of an array: charstringname[size]; for example, charstring[50]; a string of length 50 characters. Initialization uses a single character constant charstring[10]={‘H’,‘e’,‘l’,‘l’,&l

When users want to play games, they find that their facial information in safe mode does not match. This situation is easy to solve. Just re-identify. Let me show you the detailed solution steps. DNF security mode face identity information mismatch removal step 1. First enter WeChat and click the "magnifying glass" icon in the upper right corner. 2. Then enter "Growth Guardian Platform", click "Search" and find the "Health System" as shown in the figure. , 3. Then select "Real-name Authentication Query", 4. Now re-authenticate the identity, 5. After the verification is completed, click "Next".

How to handle the split and merge bill functions of the accounting system - How to split and merge bills using PHP Introduction: In daily life, we often encounter situations where we need to split and merge bills, especially in an accounting system In the system, these two functions are very common and important. This article will introduce how to use PHP to implement the split and merge bill functions in the accounting system, and provide specific code examples. 1. Implementation of the split bill function Split bill refers to the process of splitting the original bill into multiple sub-bills. Each sub-bill contains a portion of

Many times we need to split a partition into multiple partitions. Do you know how to split a partition with the partition tool diskgenius? Below, the editor will bring you a method to split a partition with the partition tool diskgenius. Let us take a look below. Bar. Select the partition to be split, right-click the mouse, and select the "Split Partition" menu item, as shown below: DiskGenius will pop up the Adjust Partition Capacity dialog box. You can set the split partition size by dragging the edge of the partition, and then click "Start" button. The software prompts the operations to be performed and precautions. Click the "Yes" button and the software starts to split the partition. Wait for the operation to complete. After the operation is completed, click the "Finish" button to adjust the partition dialog box.

We often use Excel tables in our daily office work, so are you familiar with the functions inside? Recently, friends have been asking how to operate split columns in Excel. Today I will share with you the specific steps, which are below. You can learn them carefully! We need to split the data in column A into two columns. First, select the data in column A, and then click the [Data] option at the top of the page (marked in red in the picture below). 2. Then, under the data menu bar, click the [Column] option on the right (as shown in the red circle in the figure below). 3. In the first step of column splitting, check [Fixed Width], and then click [Next] (as shown in the red circle in the figure below). 4. In the second step of sorting
