This should be easy but I can not figure this out…
How do you do a nested function? Here are the snippets…
if(isAlphabet, trimAll(FirstName, “Please enter your first name”)){
function isAlphabet(elem, helperMsg){
var alphaExp = /[1]+$/;
if(elem.value.match(alphaExp)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
Everything worked with my code but I was having a hard time submitting a form with more then one word in the text box. So I found this code…but can not figue out how to have the if statement to do both functions. Can you help, please?
Here’s the spaces function…
function trimAll( strValue ) {
var objRegExp = /^(\s*)$/;
//check for all spaces
if(objRegExp.test(strValue)) {
strValue = strValue.replace(objRegExp, '');
if( strValue.length == 0)
return strValue;
}
//check for leading & trailing spaces
objRegExp = /^(\s*)([\W\w])(\b\s$)/;
if(objRegExp.test(strValue)) {
//remove leading and trailing whitespace characters
strValue = strValue.replace(objRegExp, ‘$2’);
}
return strValue;
a-zA-Z ↩︎