Click here to Skip to main content
15,890,506 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Unable to run the website using IIS Pin
jkirkerx14-Aug-12 7:45
professionaljkirkerx14-Aug-12 7:45 
QuestionJQGRID IN ASP.NET Pin
Roshith G13-Aug-12 19:29
Roshith G13-Aug-12 19:29 
QuestionCustom Validator of Combobox and Validation summary Pin
Neha Ojha13-Aug-12 7:28
Neha Ojha13-Aug-12 7:28 
AnswerRe: Custom Validator of Combobox and Validation summary Pin
jkirkerx14-Aug-12 7:59
professionaljkirkerx14-Aug-12 7:59 
GeneralRe: Custom Validator of Combobox and Validation summary Pin
Neha Ojha15-Aug-12 5:09
Neha Ojha15-Aug-12 5:09 
GeneralRe: Custom Validator of Combobox and Validation summary Pin
jkirkerx15-Aug-12 7:41
professionaljkirkerx15-Aug-12 7:41 
GeneralRe: Custom Validator of Combobox and Validation summary Pin
Neha Ojha15-Aug-12 8:11
Neha Ojha15-Aug-12 8:11 
GeneralRe: Custom Validator of Combobox and Validation summary Pin
jkirkerx15-Aug-12 10:54
professionaljkirkerx15-Aug-12 10:54 
i use jquery

I bind an event called blur to the textbox, when the user changes fields, the blur is fired, and validates the textbox. I can then format the data, if the value is not correct, then you can paint a red border around the entire area, and change the background color of the textbox.

A red border around the textbox is more visible and non-intrusive than a giant validation message.

A Jquery file designed to work with an update panel. It validate a textbox for an email address. This is one of the designs I use. I have many designs.

$(document).ready(function () {
 
    // Load Bindings
    initiateBinding();

    // Run the PageManagerRequest Processes
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

});

function EndRequestHandler(sender, args) {
    initiateBinding();
}

function initiateBinding() {
    //Bind events here
    $(document).ajaxStart(function () {

    });

    $(document).ajaxStop(function () {

    });

    $('[id*="_txt_Email_Jquery_FriendsName_Field"]').blur(function() {
      validate_Email();
    });

}

function validate_Email() {
    var validation_Flag = true;

    var txtFocus;
    var txtError;
    txtFocus = $('[id*="_txt_Jquery_txtFocus"]').val();
    txtError = $('[id*="_txt_Jquery_txtError"]').val();

    var friendsName_length;
    friendsName_length = $('[id*="_txt_Email_Jquery_FriendsName_Field"]').val().length;
    if (friendsName_length < 2) {
        $('[id*="_txt_Email_Jquery_FriendsName_Field"]').css('background-color', txtFocus).fadeOut("slow");
        $('[id*="_txt_Email_Jquery_FriendsName_Field"]').css('background-color', txtError).fadeIn("slow");
        $('[id*="_img_Email_Jquery_FriendsName_Error"]').delay(800).fadeIn(300).show("normal");
        validation_Flag = false;
    }
    else if (friendsName_length > 2) {
        $('[id*="_txt_Email_Jquery_FriendsName_Field"]').css('background-color', txtError).fadeOut("slow");
        $('[id*="_txt_Email_Jquery_FriendsName_Field"]').css('background-color', txtFocus).fadeIn("slow");
        $('[id*="_img_Email_Jquery_FriendsName_Error"]').fadeOut(500).hide("normal");
    }

    var emailAddress_length;
    emailAddress_length = $('[id*="_txt_Email_Jquery_EmailAddress_Field"]').val().length;
    if (emailAddress_length < 2) {
        $('[id*="_txt_Email_Jquery_EmailAddress_Field"]').css('background-color', txtFocus).fadeOut("slow");
        $('[id*="_txt_Email_Jquery_EmailAddress_Field"]').css('background-color', txtError).fadeIn("slow");
        $('[id*="_img_Email_Jquery_EmailAddress_Error"]').delay(800).fadeIn(300).show("normal");
        validation_Flag = false;
    }
    else if (emailAddress_length > 2) {
        $('[id*="_txt_Email_Jquery_EmailAddress_Field"]').css('background-color', txtFocus).fadeIn("slow");
        $('[id*="_img_Email_Jquery_EmailAddress_Error"]').fadeOut(500).hide("normal");

        //Regex Email Address
        var re_EmailAddress = new RegExp("\\w+([-+.']\\w+)*@\\w+([-.]\w+)*\\.\\w+([-.]\\w+)*");
        var txt_EmailAddress_Validate = $('[id*="_txt_Email_Jquery_EmailAddress_Field"]').val();
        var match_EmailAddress = re_EmailAddress.exec(txt_EmailAddress_Validate);
        if (match_EmailAddress == null) {
            $('[id*="_txt_Email_Jquery_EmailAddress_Field"]').css('background-color', txtFocus).fadeOut("slow");
            $('[id*="_txt_Email_Jquery_EmailAddress_Field"]').css('background-color', "#C6DEFF").fadeIn("slow");
            $('[id*="_img_Email_Jquery_EmailAddress_Error"]').delay(800).fadeIn(300).show("normal");
            $('[id*="_lbl_Email_Jquery_EmailAddress_Label"]').text("Your format is not valid! (eg. someone@domain.com)").delay(800);
            //alert("email not valid");
            validation_Flag = false;

        } else if (match_EmailAddress !== null) {
            $('[id*="_txt_Email_Jquery_EmailAddress_Field"]').css('background-color', txtFocus).fadeIn("slow");
            $('[id*="_img_Email_Jquery_EmailAddress_Error"]').fadeOut(500).hide("normal");
            $('[id*="_lbl_Email_Jquery_EmailAddress_Label"]').text("Enter your friends email address:").delay(500);
        }
    }

    if (validation_Flag == true) {
        $('[id*="_txt_Jquery_Approved"]').val("jquery_approved");
    }
    else {
        $('[id*="_txt_Jquery_Approved"]').val("jquery_declined");
    }
}

GeneralRe: Custom Validator of Combobox and Validation summary Pin
Neha Ojha21-Aug-12 4:06
Neha Ojha21-Aug-12 4:06 
GeneralRe: Custom Validator of Combobox and Validation summary Pin
jkirkerx21-Aug-12 10:27
professionaljkirkerx21-Aug-12 10:27 
QuestionASP.net Error [Solved] Pin
jojoba201113-Aug-12 3:24
jojoba201113-Aug-12 3:24 
AnswerRe: ASP.net Error [SOLVED] Pin
jojoba201113-Aug-12 18:35
jojoba201113-Aug-12 18:35 
QuestionServer Error in '/' Application Pin
Member 916988712-Aug-12 14:43
Member 916988712-Aug-12 14:43 
QuestionRe: Server Error in '/' Application Pin
Sandeep Mewara12-Aug-12 19:49
mveSandeep Mewara12-Aug-12 19:49 
AnswerRe: Server Error in '/' Application Pin
Member 916988712-Aug-12 22:36
Member 916988712-Aug-12 22:36 
GeneralRe: Server Error in '/' Application Pin
Eddy Vluggen12-Aug-12 23:11
professionalEddy Vluggen12-Aug-12 23:11 
GeneralRe: Server Error in '/' Application Pin
Vijay Selvaraj27-Aug-12 0:17
Vijay Selvaraj27-Aug-12 0:17 
GeneralRe: Server Error in '/' Application Pin
Eddy Vluggen27-Aug-12 0:21
professionalEddy Vluggen27-Aug-12 0:21 
Questionbring footer to bottom Pin
Jassim Rahma12-Aug-12 12:32
Jassim Rahma12-Aug-12 12:32 
QuestionGridview Pin
sravsailu12-Aug-12 6:17
sravsailu12-Aug-12 6:17 
AnswerRe: Gridview Pin
Wes Aday12-Aug-12 6:45
professionalWes Aday12-Aug-12 6:45 
GeneralRe: Gridview Pin
sravsailu12-Aug-12 7:05
sravsailu12-Aug-12 7:05 
Questionhow to extrack an image from an email and save it on a disk Pin
Member 798388410-Aug-12 18:17
Member 798388410-Aug-12 18:17 
AnswerRe: how to extrack an image from an email and save it on a disk Pin
Richard MacCutchan10-Aug-12 21:53
mveRichard MacCutchan10-Aug-12 21:53 
Questionsession variables Pin
sc steinhayse10-Aug-12 17:28
sc steinhayse10-Aug-12 17:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.