From: Roberto C. - S. S. <rob...@fi...> - 2003-01-23 12:30:33
|
----- Original Message ----- From: "Ondrej Jombik" <ne...@po...> To: "Roberto Cohen - SIAL Software" <rob...@fi...> Cc: <php...@li...> Sent: Wednesday, January 15, 2003 11:34 AM Subject: Re: [PHPMyEdit-Discuss] ['required'] = true will generate javascript to prevent null entries by users > Yes, I like the idea. Please post me a JavaScript "trim()" function implementation, I can add it in phpMyEdit. I suppose we can simple remove the current implementation by adding this feature, since probably nobody willl need ['required'] for spaces and/or other white characters. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is. I didn't study the core code of PHPMYEDIT. I think is better for us :o) I tested this in IE 6.0 and Netscape 7.0 and is running OK to warning about "only spaces in form field". ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <SCRIPT LANGUAGE="JavaScript"> function Trim(trimInputString) { while(trimInputString.charAt(0)==" ") trimInputString=trimInputString.substring(1,trimInputString.length); while(trimInputString.charAt(trimInputString.length-1)==" ") trimInputString=trimInputString.substring(0,trimInputString.length-1); return (trimInputString); } function page(){ if (Trim(document.form1.name.value) == 0){ alert("Please, fill information in name.") document.form1.name.focus(); return false} } </SCRIPT> </HEAD> <BODY> <FORM METHOD=post NAME="form1" onSubmit="return page()"> your name: <input name="name" size="30" > <input type="submit" value="submit"> </TR> </form> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Regards. Cordialmente Roberto Cohen Come to South Brazil Porto Alegre - World Social Forum http://www.forumsocialmundial.org.br |