RE: [Phplib-users] How to validate a oohform with js ?
Brought to you by:
nhruby,
richardarcher
From: Taylor, S. <Ste...@uk...> - 2002-10-30 15:49:57
|
$f = new form; $f->add_element(.... ... $f->start("MyFunction","POST","index.php","","FormName"); ^^^^ This parameter specifies that you want to create a form onsubmit javascript function. ... $f->finsh("", " if (f.input1.value=='' && f.input2.value=='') { alert('your message'); return false; } " ); Use the finish function to put none phplib generated code into the onsubmit function. i.e. function finish($after, $before) Therefore, the above call will add onsubmit attribute to the form tag <FORM ......."onsubmit"="return MyFunction_Validator(this)"> ... And generate the javascript function code. <SCRIPT> function MyFunction_Validator(f) { // $before if (f.input1.value=='' && f.input2.value=='') { alert('your message'); return false; } phplib generated javascript code // $after ... } </SCRIPT> ... -Stewart -----Original Message----- From: Benjamin Hoft [mailto:ho...@eu...] Sent: 30 October 2002 15:27 To: 'Php...@li...' Subject: [Phplib-users] How to validate a oohform with js ? How can i validate if either one or the other of two textfields (or both) is being fillied with some sort of text ? normally i would use js with a script like this: <SCRIPT> function validate() { if (document.form.input1.value=="" && document.form.input2.value=="") { alert ("please insert some text in one of the input fields"); } else { document.form.submit(); } } </SCRIPT> and use this function on a link <a href="javascript:Validate();">submit</a> but how can i do that with phplib, with oohforms and templates ? i couly only validate both fields if they are empty, but what if only one must be entered with text ? best regards Benjamin ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Phplib-users mailing list Php...@li... https://lists.sourceforge.net/lists/listinfo/phplib-users |