You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
285 lines
10 KiB
285 lines
10 KiB
class onInput { |
|
persianOnly = (txt) => { |
|
let newText = txt; |
|
newText = newText.replace(/`/g, ""); |
|
newText = newText.replace(/0/g, ""); |
|
newText = newText.replace(/1/g, ""); |
|
newText = newText.replace(/2/g, ""); |
|
newText = newText.replace(/3/g, ""); |
|
newText = newText.replace(/4/g, ""); |
|
newText = newText.replace(/5/g, ""); |
|
newText = newText.replace(/6/g, ""); |
|
newText = newText.replace(/7/g, ""); |
|
newText = newText.replace(/8/g, ""); |
|
newText = newText.replace(/9/g, ""); |
|
newText = newText.replace(/0/g, ""); |
|
newText = newText.replace(/q/g, ""); |
|
newText = newText.replace(/w/g, ""); |
|
newText = newText.replace(/e/g, ""); |
|
newText = newText.replace(/r/g, ""); |
|
newText = newText.replace(/t/g, ""); |
|
newText = newText.replace(/y/g, ""); |
|
newText = newText.replace(/u/g, ""); |
|
newText = newText.replace(/i/g, ""); |
|
newText = newText.replace(/o/g, ""); |
|
newText = newText.replace(/p/g, ""); |
|
newText = newText.replace(/\[/g, ""); |
|
newText = newText.replace(/\]/g, ""); |
|
newText = newText.replace(/a/g, ""); |
|
newText = newText.replace(/s/g, ""); |
|
newText = newText.replace(/d/g, ""); |
|
newText = newText.replace(/f/g, ""); |
|
newText = newText.replace(/g/g, ""); |
|
newText = newText.replace(/h/g, ""); |
|
newText = newText.replace(/j/g, ""); |
|
newText = newText.replace(/k/g, ""); |
|
newText = newText.replace(/l/g, ""); |
|
newText = newText.replace(/;/g, ""); |
|
newText = newText.replace(/'/g, ""); |
|
newText = newText.replace(/z/g, ""); |
|
newText = newText.replace(/x/g, ""); |
|
newText = newText.replace(/c/g, ""); |
|
newText = newText.replace(/v/g, ""); |
|
newText = newText.replace(/b/g, ""); |
|
newText = newText.replace(/n/g, ""); |
|
newText = newText.replace(/m/g, ""); |
|
newText = newText.replace(/,/g, ""); |
|
newText = newText.replace(/./g, ""); |
|
newText = newText.replace(/\//g, ""); |
|
newText = newText.replace(/~/g, " "); |
|
newText = newText.replace(/Q/g, ""); |
|
newText = newText.replace(/W/g, ""); |
|
newText = newText.replace(/E/g, ""); |
|
newText = newText.replace(/R/g, ""); |
|
newText = newText.replace(/T/g, ""); |
|
newText = newText.replace(/Y/g, ""); |
|
newText = newText.replace(/U/g, ""); |
|
newText = newText.replace(/I/g, ""); |
|
newText = newText.replace(/O/g, ""); |
|
newText = newText.replace(/P/g, ""); |
|
newText = newText.replace(/A/g, ""); |
|
newText = newText.replace(/S/g, ""); |
|
newText = newText.replace(/G/g, ""); |
|
newText = newText.replace(/H/g, ""); |
|
newText = newText.replace(/J/g, ""); |
|
newText = newText.replace(/K/g, ""); |
|
newText = newText.replace(/L/g, ""); |
|
newText = newText.replace(/Z/g, ""); |
|
newText = newText.replace(/X/g, ""); |
|
newText = newText.replace(/B/g, ""); |
|
newText = newText.replace(/N/g, ""); |
|
newText = newText.replace(/M/g, ""); |
|
newText = newText.replace(/\?/g, ""); |
|
if (!newText && newText.length !== 0) { |
|
} |
|
return newText; |
|
}; |
|
englishAndNumberWithoutSpace = (txt) => { |
|
let newText = txt; |
|
newText = newText.replace(/`/g, ""); |
|
newText = newText.replace(/0/g, "0"); |
|
newText = newText.replace(/1/g, "1"); |
|
newText = newText.replace(/2/g, "2"); |
|
newText = newText.replace(/3/g, "3"); |
|
newText = newText.replace(/4/g, "4"); |
|
newText = newText.replace(/5/g, "5"); |
|
newText = newText.replace(/6/g, "6"); |
|
newText = newText.replace(/7/g, "7"); |
|
newText = newText.replace(/8/g, "8"); |
|
newText = newText.replace(/9/g, "9"); |
|
newText = newText.replace(/ا/g, ""); |
|
newText = newText.replace(/ب/g, ""); |
|
newText = newText.replace(/پ/g, ""); |
|
newText = newText.replace(/ت/g, ""); |
|
newText = newText.replace(/ث/g, ""); |
|
newText = newText.replace(/ج/g, ""); |
|
newText = newText.replace(/چ/g, ""); |
|
newText = newText.replace(/ح/g, ""); |
|
newText = newText.replace(/خ/g, ""); |
|
newText = newText.replace(/د/g, ""); |
|
newText = newText.replace(/\[/g, ""); |
|
newText = newText.replace(/\]/g, ""); |
|
newText = newText.replace(/ذ/g, ""); |
|
newText = newText.replace(/ر/g, ""); |
|
newText = newText.replace(/ز/g, ""); |
|
newText = newText.replace(/ژ/g, ""); |
|
newText = newText.replace(/ط/g, ""); |
|
newText = newText.replace(/ظ/g, ""); |
|
newText = newText.replace(/ع/g, ""); |
|
newText = newText.replace(/غ/g, ""); |
|
newText = newText.replace(/ف/g, ""); |
|
newText = newText.replace(/;/g, ""); |
|
newText = newText.replace(/'/g, ""); |
|
newText = newText.replace(/ق/g, ""); |
|
newText = newText.replace(/س/g, ""); |
|
newText = newText.replace(/ش/g, ""); |
|
newText = newText.replace(/ص/g, ""); |
|
newText = newText.replace(/ض/g, ""); |
|
newText = newText.replace(/ک/g, ""); |
|
newText = newText.replace(/گ/g, ""); |
|
newText = newText.replace(/,/g, ""); |
|
newText = newText.replace(/\./g, ""); |
|
newText = newText.replace(/\//g, ""); |
|
newText = newText.replace(/~/g, " "); |
|
newText = newText.replace(/ل/g, ""); |
|
newText = newText.replace(/م/g, ""); |
|
newText = newText.replace(/ن/g, ""); |
|
newText = newText.replace(/و/g, ""); |
|
newText = newText.replace(/ه/g, ""); |
|
newText = newText.replace(/ی/g, ""); |
|
newText = newText.replace(/\?/g, ""); |
|
if (!newText && newText.length !== 0) { |
|
} |
|
return newText; |
|
}; |
|
numberOnly = (txt) => { |
|
let newText = txt; |
|
newText = newText.replace(/`/g, ""); |
|
newText = newText.replace(/0/g, "0"); |
|
newText = newText.replace(/1/g, "1"); |
|
newText = newText.replace(/2/g, "2"); |
|
newText = newText.replace(/3/g, "3"); |
|
newText = newText.replace(/4/g, "4"); |
|
newText = newText.replace(/5/g, "5"); |
|
newText = newText.replace(/6/g, "6"); |
|
newText = newText.replace(/7/g, "7"); |
|
newText = newText.replace(/8/g, "8"); |
|
newText = newText.replace(/9/g, "9"); |
|
newText = newText.replace(/۰/g, "0"); |
|
newText = newText.replace(/۱/g, "1"); |
|
newText = newText.replace(/۲/g, "2"); |
|
newText = newText.replace(/۳/g, "3"); |
|
newText = newText.replace(/۴/g, "4"); |
|
newText = newText.replace(/۵/g, "5"); |
|
newText = newText.replace(/۶/g, "6"); |
|
newText = newText.replace(/۷/g, "7"); |
|
newText = newText.replace(/۸/g, "8"); |
|
newText = newText.replace(/۹/g, "9"); |
|
newText = newText.replace(/ا/g, ""); |
|
newText = newText.replace(/ب/g, ""); |
|
newText = newText.replace(/پ/g, ""); |
|
newText = newText.replace(/ت/g, ""); |
|
newText = newText.replace(/ث/g, ""); |
|
newText = newText.replace(/ج/g, ""); |
|
newText = newText.replace(/چ/g, ""); |
|
newText = newText.replace(/ح/g, ""); |
|
newText = newText.replace(/خ/g, ""); |
|
newText = newText.replace(/د/g, ""); |
|
newText = newText.replace(/\[/g, ""); |
|
newText = newText.replace(/\]/g, ""); |
|
newText = newText.replace(/ذ/g, ""); |
|
newText = newText.replace(/ر/g, ""); |
|
newText = newText.replace(/ز/g, ""); |
|
newText = newText.replace(/ژ/g, ""); |
|
newText = newText.replace(/ط/g, ""); |
|
newText = newText.replace(/ظ/g, ""); |
|
newText = newText.replace(/ع/g, ""); |
|
newText = newText.replace(/غ/g, ""); |
|
newText = newText.replace(/ف/g, ""); |
|
newText = newText.replace(/;/g, ""); |
|
newText = newText.replace(/'/g, ""); |
|
newText = newText.replace(/ق/g, ""); |
|
newText = newText.replace(/س/g, ""); |
|
newText = newText.replace(/ش/g, ""); |
|
newText = newText.replace(/ص/g, ""); |
|
newText = newText.replace(/ض/g, ""); |
|
newText = newText.replace(/ک/g, ""); |
|
newText = newText.replace(/گ/g, ""); |
|
newText = newText.replace(/\,/g, ""); |
|
newText = newText.replace(/\./g, ""); |
|
newText = newText.replace(/\//g, ""); |
|
newText = newText.replace(/~/g, " "); |
|
newText = newText.replace(/ل/g, ""); |
|
newText = newText.replace(/م/g, ""); |
|
newText = newText.replace(/ن/g, ""); |
|
newText = newText.replace(/و/g, ""); |
|
newText = newText.replace(/ه/g, ""); |
|
newText = newText.replace(/ی/g, ""); |
|
newText = newText.replace(/\?/g, ""); |
|
newText = newText.replace(/q/g, ""); |
|
newText = newText.replace(/w/g, ""); |
|
newText = newText.replace(/e/g, ""); |
|
newText = newText.replace(/r/g, ""); |
|
newText = newText.replace(/t/g, ""); |
|
newText = newText.replace(/y/g, ""); |
|
newText = newText.replace(/u/g, ""); |
|
newText = newText.replace(/i/g, ""); |
|
newText = newText.replace(/o/g, ""); |
|
newText = newText.replace(/p/g, ""); |
|
newText = newText.replace(/a/g, ""); |
|
newText = newText.replace(/s/g, ""); |
|
newText = newText.replace(/d/g, ""); |
|
newText = newText.replace(/f/g, ""); |
|
newText = newText.replace(/g/g, ""); |
|
newText = newText.replace(/h/g, ""); |
|
newText = newText.replace(/j/g, ""); |
|
newText = newText.replace(/k/g, ""); |
|
newText = newText.replace(/l/g, ""); |
|
newText = newText.replace(/z/g, ""); |
|
newText = newText.replace(/x/g, ""); |
|
newText = newText.replace(/c/g, ""); |
|
newText = newText.replace(/v/g, ""); |
|
newText = newText.replace(/b/g, ""); |
|
newText = newText.replace(/n/g, ""); |
|
newText = newText.replace(/m/g, ""); |
|
newText = newText.replace(/Q/g, ""); |
|
newText = newText.replace(/W/g, ""); |
|
newText = newText.replace(/E/g, ""); |
|
newText = newText.replace(/R/g, ""); |
|
newText = newText.replace(/T/g, ""); |
|
newText = newText.replace(/Y/g, ""); |
|
newText = newText.replace(/U/g, ""); |
|
newText = newText.replace(/I/g, ""); |
|
newText = newText.replace(/O/g, ""); |
|
newText = newText.replace(/P/g, ""); |
|
newText = newText.replace(/A/g, ""); |
|
newText = newText.replace(/S/g, ""); |
|
newText = newText.replace(/G/g, ""); |
|
newText = newText.replace(/H/g, ""); |
|
newText = newText.replace(/J/g, ""); |
|
newText = newText.replace(/K/g, ""); |
|
newText = newText.replace(/L/g, ""); |
|
newText = newText.replace(/Z/g, ""); |
|
newText = newText.replace(/X/g, ""); |
|
newText = newText.replace(/B/g, ""); |
|
newText = newText.replace(/N/g, ""); |
|
newText = newText.replace(/M/g, ""); |
|
if (!newText && newText.length !== 0) { |
|
|
|
} |
|
return newText; |
|
}; |
|
dayHandler = (num) => { |
|
let newNum = this.numberOnly(num); |
|
if (newNum > 31) { |
|
return Math.floor(newNum / 10); |
|
} |
|
return newNum; |
|
}; |
|
monthHandler = (num) => { |
|
let newNum = this.numberOnly(num); |
|
if (newNum > 12 || newNum < 0) { |
|
return Math.floor(newNum / 10); |
|
} |
|
return newNum; |
|
}; |
|
yearHandler = (num) => { |
|
let newNum = this.numberOnly(num); |
|
if (newNum > 1395) { |
|
return Math.floor(newNum / 10); |
|
} |
|
return newNum; |
|
}; |
|
phonenumber = (value) => { |
|
let formattedValue = value |
|
.replace(/[\u0660-\u0669\u06f0-\u06f9]/g, function (c) { |
|
return c.charCodeAt(0) & 0xf; |
|
}) |
|
.replace(/[^\d]/, ""); |
|
return formattedValue; |
|
}; |
|
} |
|
|
|
const _onInput = new onInput(); |
|
|
|
export default _onInput;
|
|
|