javascript - Server side validation results appear in the same browser window -
javascript - Server side validation results appear in the same browser window -
simple html form:
<form action="test.php" method="post" name="my_form" id="my_form" > <input name="c_name" type="text" id="c_name" maxlength="90"/> </form>
test.php next code:
<?php $name=$_post['c_name']; if ((!isset($name)) || ($name=='')) { echo 'fill in name'; } else { echo $name; } ?>
now, want next upon form submission:
1) not leave current browser window php display corresponding message.i want form window remain there.
2)i not want simple response message. example, want instead of "fill in name" more graphical way interact making hidden div appear; in other words want write jquery within php , create execute. possible , how?
i know have utilize ajax, not know exactly! give me code realise above 2 things?
i believe if you're new of this, seem are, best of using jquery indeed. ajax illustration can found here: http://api.jquery.com/jquery.ajax/
code in case q bit extensive. cause not want check if in fact empty, want preg_match it. means want create sure users send want (and not break or hack or inject server, important).
so seeing recommend read tutorial, (fast google search): http://code.tutsplus.com/tutorials/5-ways-to-make-ajax-calls-with-jquery--net-6289
and familiarize basics before getting next steps.
javascript php jquery html ajax
Comments
Post a Comment