function trimString( s ) { var index = s.length; while( index > 0 && ( c = s.charAt( index - 1 ) ) != null ) { if( c == ' ' || c == '\t' ) { index--; } else { break; } } s = s.substring( 0 , index ); index = 0; while( ( c = s.charAt( index ) ) != null ) { if( c == ' ' || c == '\t' ) { index++; } else { break; } } return s.substring( index , s.length ); } function testHeltal( s ) { s = trimString ( s ) ; for( var i = 0; i < s.length; i++) { if(s.charAt(i) == "." || s.charAt(i) == ",") { alert("Undlad venligst at bruge tusindtalsseperatorer."); return false; } if( s.charAt( i ) < "0" || s.charAt( i ) > "9" ) { return false; } } return true; } /* @routine activeClearForm @date 27.jan. 2009 @author PY @desc Clear form-element @enddesc */ function activeClearForm(el) { if (el.defaultValue == el.value) { el.value = ""; } } /* @routine validateEmail @date 27.jan. 2009 @author PY @desc Validate text to ensure valid email-address @enddesc @par txtboxUsername @pdesc set to text that needs validating @ptype textbox @endpar @par errorMessage @pdesc set to text that should appear if email is invalid @ptype string @endpar */ var emailregexp = /^([A-Z0-9_\.\-]+)@([A-Z0-9]+)([.,_,-]([A-Z0-9]+))*\.[A-Z]{2,4}$/i; function validateEmail(txtboxUsername, errorMessage) { if (!emailregexp.test(txtboxUsername.value)) { txtboxUsername.value = errorMessage; return false; } return true; }