Jump to content
bubbles

Problema validare javascript + php

Recommended Posts

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>
<?php

if ( 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 ?

Link to comment
Share on other sites

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 by evangilbort
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...