...

View Full Version : Validate email?



mdj101
02-21-2008, 12:37 PM
Hi All,

I'm sure this will be a quick one for most of you.

I have the following code in an asp script to check a form, but how can i check that the email field has the required elements i.e. a@b.com



Response.Write( "<script language=""JavaScript"" type=""text/javascript"">" & vbCrLf)
Response.Write( "<!--" & vbCrLf)
Response.Write( "function checkform ( form )" & vbCrLf)
Response.Write( "{" & vbCrLf)
Response.Write( " if (form.ratingtitle.value == """") {" & vbCrLf)
Response.Write( " alert( ""Please enter a title."" );" & vbCrLf)
Response.Write( " form.ratingtitle.focus();" & vbCrLf)
Response.Write( " return false ;" & vbCrLf)
Response.Write( " }" & vbCrLf)

Response.Write( " if (form.ratingcomment.value == """") {" & vbCrLf)
Response.Write( " alert( ""Please enter your comment."" );" & vbCrLf)
Response.Write( " form.ratingcomment.focus();" & vbCrLf)
Response.Write( " return false ;" & vbCrLf)
Response.Write( " }" & vbCrLf)

Response.Write( " if (form.ratinglocation.value == """") {" & vbCrLf)
Response.Write( " alert( ""Please enter your location."" );" & vbCrLf)
Response.Write( " form.ratinglocation.focus();" & vbCrLf)
Response.Write( " return false ;" & vbCrLf)
Response.Write( " }" & vbCrLf)

Response.Write( " if (form.ratingname.value == """") {" & vbCrLf)
Response.Write( " alert( ""Please enter your name."" );" & vbCrLf)
Response.Write( " form.ratingname.focus();" & vbCrLf)
Response.Write( " return false ;" & vbCrLf)
Response.Write( " }" & vbCrLf)

Response.Write( " if (form.ratingemail.value == """") {" & vbCrLf)
Response.Write( " alert( ""Please enter your email address."" );" & vbCrLf)
Response.Write( " form.ratingemail.focus();" & vbCrLf)
Response.Write( " return false ;" & vbCrLf)
Response.Write( " }" & vbCrLf)


Response.Write( " return true ;" & vbCrLf)
Response.Write( "}" & vbCrLf)
Response.Write( "//-->" & vbCrLf)
Response.Write( "</script>" & vbCrLf)

Kor
02-21-2008, 03:24 PM
use RegExp:
http://lawrence.ecorp.net/inet/samples/regexp-intro.php
http://lawrence.ecorp.net/inet/samples/regexp-validate.php

mdj101
02-21-2008, 03:40 PM
mmmm..... LOST!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum