Form Validation - proper method for client and server side using PHP & Javascript -


--edit-- (trying rephrase question less confusing..)

my understanding should validate forms both client , server side in case javascript not working.

how advanced developers accomplish in seamless interface (if 1 had describe in general manner)?

currently have javascript validating input fields on fly 'onkeyup ()', highlighting invalid fields.

if run same validations php after user submits, have redirect form if there errors, refreshing page.

i thought method lacking sophistication.

what best method?

thanks in advance.

--- original question below ---

so created form client side javascript validate input user types. highlights boxes w red borders if data invalid (using javascript alter css). re-validate same data php server side in case of problems javascript client side.

i trying figure out proper (or best) way accomplish this.

currently form action setup go "register_post.php" after user hits submit.

--

so validate form data in php in "register_post.php", , redirect form page if invalid, or there more sophisticated way this?

one annoying result of page refreshing when page redirected.

is there more sophisticated way this?

--

another related question - should prep code javascript not working @ all? ..since currently, use javascript highlight fields if data invalid. user have no indication of fields invalid without js.

please bear me beginner.

you trying valid post data php , without refresh page, don't know if point right. if want valid data php , without refreshing page, use ajax. can use javascript post data php script , deal php return data.

an example of jquery ajax method :

<script> var validdataarr = '';  //data need valided $.ajax({             type:"post",url:"http://"+top.location.hostname+"/valid.php",             data:validdataarr,             success:function(context){alert(context);}          }); </script> 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -