MiYavI Posted March 29, 2008 Report Share Posted March 29, 2008 Tātad ir tāds kods: <script> function validate(f) { if(f.niks.value=="") { alert("Ierakstiet niku!"); f.niks.style.background = "silver"; return false; } else if (f.parole.value == "") { alert("Ierakstiet paroli"); f.parole.style.background = "silver"; return false; } else if (f.parole2.value == "") { alert("Ierakstiet paroli atkārtoti"); f.parole.style2.background = "silver"; return false; } else if (f.parole.value != f.parole2.value) { alert("Paroles nesakrīt"); f.parole.style.background = "yellow"; f.parole2.style.background = "yellow"; return false; } return true; } </script> <form action=get_reg.php method=POST onsubmit="return validate(this)" > Niks: <input type=text name=niks id=niks><br> Parole: <input type=password name=palore id=parole><br> Parole 2: <input type=password name=parole2 id=parole><br> <input type=submit value=Ok> </form> Un nestrādā.. It kā, ja izņemu tos paroles validate, tad strādā.. Jeb tad strādā tikai nika pārbaude.. bet man vajag visus. Link to comment Share on other sites More sharing options...
777 Posted March 29, 2008 Report Share Posted March 29, 2008 (edited) onsubmit="validate(this); return false;" Edited March 29, 2008 by 777 Link to comment Share on other sites More sharing options...
MiYavI Posted March 30, 2008 Author Report Share Posted March 30, 2008 It kā pārbauda, bet kad piem parādās Paroles nesakrīt, tad viņš neizsauc return false, jeb izpilda form action (get_reg.php) Link to comment Share on other sites More sharing options...
john.brown Posted March 30, 2008 Report Share Posted March 30, 2008 saliec pareizus lauku nosaukumus un id, un un funkciju izsauc ne uz formas onSubmit, bet buttona onClick. bet submito ar f.submit() returna vietā. un pēdiņās tomēr labi būtu visus tos lauku parametrus likt. Link to comment Share on other sites More sharing options...
indoom Posted March 31, 2008 Report Share Posted March 31, 2008 Parole: <input type=password name=palore id=parole> Link to comment Share on other sites More sharing options...
Recommended Posts