Jump to content

form validating help


darkcarnival

Recommended Posts

hi,

I wish to use either ajax or js or both to validate my php script.

now i am new to js & ajax so im curious if anyone can direct me to a good tutorial or some tips on this.

what I'm looking for?

-when an error occurs a message appears next to the form box

might want this to be ajax-based so that it can check this before anything processes.

i know ipb does something similar, so if someone knows how they do it, that'd help even more.

thank you in advance.
Link to comment
https://forums.phpfreaks.com/topic/34920-form-validating-help/
Share on other sites

Use javascript to valiate basic things,
like wether en email address is really an email address,
or if the number you products you want to order is an actual interger.

Use ajax to validate specific things,
like if your particular email address is in a database.

[code]
<script>
function validate()
{
var e = document.getElementById('thing').value;
if (e == '') {alert('dude, its blank');}
else if (isNaN(e)) {alert('dude, thats not a number');}
    else {alert('ok, looks good.')}
}

<input type="text" id="thing" name="thing">
<input type="button" onclick="validate();" value="check">
</script>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/34920-form-validating-help/#findComment-165968
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.