|
parseInt
let n = parseInt(sn);parseFloat
let n = parseFloat(sn,10);
IsNaN
if ( isNaN(sn) ) {
} else {
} // if isNaN
String methods
let n = str_input.length; .indexOf("abc"); // return the position of abc, -1=not found, no regular expression, faster item = item.replace("abc", "xyz"); // extract from the string, start, end (0->n-1) // startindex<y0, then it start from the end .slice(1,5); var items = mystring.split(','); // split the string between the comma .substr(1,5); // start<= chars <= end; (0->n-1) .substring(1,5); // start<= chars < end; (0->n-1) .toLowerCase(); .toUpperCase(); .trim(); // remove the spaces at the start and end
Array
let n = str_input.length;
Regex
let regex = new RegExp('^[A-ZÄÖÜ]{1,1}[a-zäüöß]{1,29}$'); if (!regex.test(form.firstname.value)) { alert('Fehlerhafter Vorname'); return; }
|
|