Page 1 of 1
php or javascript?
Posted: Fri Nov 07, 2003 7:56 am
by shadow_blade47
hi there, I'm looking into various ways of validating a inputted e-mail address in a form. Should I use javascript or php to check things like whether it contains an '@' smybol? I was told javascript would do it faster, is this true? thanks,
james
Posted: Fri Nov 07, 2003 8:02 am
by Wayne
javascript will prevent the user from having to submit the page and the php script running then passing it back to the browser, because it doesnt have a valid email address, so yes it will be faster. However, you will still need to do some checking in the php script as users may have turned off javascript.
Posted: Fri Nov 07, 2003 8:05 am
by Johnm
For this task JavaScript would work well as it is done on the client side and would allow instant validation. PHP would have to be submitted in order to validate. Both would work but JS is certainly the way to go in my opinnion.
John M
Posted: Fri Nov 07, 2003 9:55 am
by twigletmac
Always remember that Javascript can be turned off - use JS validation to avoid repeated calls to the server, but always make sure you check stuff server side as well. Never trust your users.
Mac
Posted: Fri Nov 07, 2003 10:10 am
by mesz
I came to the site ready to ask a question about php to javascript and here is the thread!
Code: Select all
function maak_code()
{
var raam = window.open('','vmlcode','height=600,width=600');
raam.document.open();
with(raam.document){
write('<html>\n');
write('<head>\n<title>VML code</title>\n</head>\n');
write('<body bgcolor="buttonface">\n');
write('<center>\n<form>\n');
write('<textarea style="width: 500px; height: 500px;">\n');
write('<html>\n<head>\n\n');
write('<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v"/>\n');
write('<style type="text/css">\nv\\:* { behavior: url(#default#VML);}\n</style>\n\n');
write('</head>\n<body>\n\n');
write(document.framesї0].document.body.innerHTML.replace(/<br>/gi, '\n'));
write('\n\n</body>\n</html>\n');
write('</textarea>\n<br>\n');
write('<input type="button" value="Select" style="font-family: Verdana, Arial; font-size: 12px; width: 150px; margin-top: 8px;" onclick="document.formsї0].elementsї0].select()">\n');
write('</form>\n</center>\n');
write('</body>\n');
write('</html>');
}
raam.document.close();
raam.focus();
}
How the hell do I capture the VML code that is written to the window as PHP.
PHP is all I know - and not much of that - and so for my users to save the drawings I can only manipulate PHP .
Please, can I have a tip, a direction to help me capture the generated VML code as PHP.
This is not for profit...this is for a community site
unitedartcity
Posted: Fri Nov 07, 2003 10:22 am
by php_wiz_kid
BOTH!!
Posted: Fri Nov 07, 2003 10:28 am
by mesz
php_wiz_kid wrote:BOTH!!
What does that mean?
Posted: Fri Nov 07, 2003 10:33 am
by php_wiz_kid
Sorry, I didn't read your post, I was responding to the validate post. Sorry again.
Posted: Fri Nov 07, 2003 10:41 am
by mesz
Fair enough, no problem...do you know the answer though, I dont know where to begin...
