bubbles Posted April 23, 2013 Report Posted April 23, 2013 Am urmatorul cod :<script type="text/javascript">function v_title() { var tgt=document.getElementById("title"); if (tgt.value=='') { return 0; } else { return 1;} }function v_keywords() { var tgt=document.getElementById("keywords"); if (tgt.value=='') { return 0; } else { return 1; } }function v_submit() { var ok=0; ok+=v_title(); ok+=v_keywords(); if(ok==2) document.f_formular.submit(); else alert("Formularul nu este completat corect."); }</script><?phpif ( isset( $_POST['xxxx'] ) ) { echo "test test test "; }?><form method="post" name="f_formular" action=""><input type="text" name="title" id="title" /><br/> <input type="text" name="keywords" id="keywords" /><br/> <input type="button" onclick="v_submit();" name="xxxx" value="Add"/></form>Nu inteleg si nici nu reusesc sa fac sa afiseze test test test cand apas pe butonul xxxx dupa ce trece si de validarea facuta in javascript. if ( isset( $_POST['xxxx'] ) ) { echo "test test test "; }Care este problema ? Quote
eusimplu Posted April 23, 2013 Report Posted April 23, 2013 (edited) Ce nu-ti functioneaza mai exact?Nu face submit? Edited April 23, 2013 by eusimplu Quote
bhackery Posted April 23, 2013 Report Posted April 23, 2013 pune if ( isset( $_POST['title'] ) ) { echo "test test test "; }pentru ca $_POST['xxxx'] nu exista ... verifica cu print_r($_POST) Quote
GarryOne Posted April 23, 2013 Report Posted April 23, 2013 pune if ( isset( $_POST['title'] ) ) { echo "test test test "; }pentru ca $_POST['xxxx'] nu exista ... verifica cu print_r($_POST) Nu exista pentru ca a pus <input type="button" . Nu exista type="button" , exista doar type="submit". Quote
bubbles Posted April 23, 2013 Author Report Posted April 23, 2013 Merci tuturor. Greselile mele. Quote
eusimplu Posted April 23, 2013 Report Posted April 23, 2013 Nu exista pentru ca a pus <input type="button" . Nu exista type="button" , exista doar type="submit".Exista:type=button este pentru un simplu buton.type=submit este pentru submitul forumului. Quote
evangilbort Posted May 1, 2013 Report Posted May 1, 2013 (edited) JavaScript can be used to validate data in HTML forms before sending off the content to a server. I am having some trouble with this script for form validation, using initially java script and then validating again and the submitting with php. Edited May 1, 2013 by evangilbort Quote