6
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by tyson567
-2
Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        TextBox1.BackColor = Color.White
        Dim temp As String
        temp = TextBox1.Text
        'Dim conditon As Boolean = False
        If emailaddresscheck(temp) = True Then
            ': If emailaddresscheck(conditon) = True Then
            TextBox1.BackColor = Color.Green
        Else
            'MessageBox.Show("Please enter your email address correctly", "Incorrect Email Entry")
            'TextBox1.Text = ""
            TextBox1.BackColor = Color.Yellow
        End If

    End Sub

I have stopped the message cause it will never allow to enter valid email unless you copy and paste.

Also try this pattern

Dim pattern As String = "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

Regards,

Edited by GarryHillton

0

@GarryHillton why do you post .NET code in a php thread? This is just spam...
On topic: you can use javascript to validate the email address immediatly.
This can be used to check if the email address is in a valid format ( http://www.marketingtechblog.com/javascript-regex-emailaddress/ )

If you need additional validation (checking that an email address is not already in use in your application, ..) you should use AJAX to connect back to the server and check this. You can either use raw AJAX but I advise you to use Jquery instead as it deals with the low level details of AJAX.

0

U need the latest jquery may be jquery-1.7.2.js

http://code.jquery.com/jquery-1.7.2.js

& validation library

http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js

and few codes in javascript

<script type='text/javascript'>

$(document).ready(function(){

// Validation

 $("#yourForm").validate({
 rules:{
 email:{required:true,email:true},
 },

messages:{
email:{
 required:"Enter your email address",
 email:"Must be valid email address"},
 }
 });
 });
 </script>

'yourForm' is the id of your form...I have given u directions and almost 90% of script.....Rest is on your part to include proper error class and success class in the code above and proper css for the success and error class...try to learn jquery which makes good on page events....if you learn it you can even submit the form in the same page.

Edited by tyson567

0

i m asking about how to write code in php to give a proper message of validation for email address after entered email adress text box

0

In php you can validate only if the form is submitted not after entering the text inside form...
Your question directed me towards jquery...

in php u can do it by

if(empty($_POST['email'])){
    echo "Email Field Empty!";
    exit;
}
    if(!filter_var($_POST[email], FILTER_VALIDATE_EMAIL))
{
exit("Please Enter Valid Email id");
}

Above two Snippets will do it!

Please Post your question properly

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.