Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.Net Login control validation with jQuery

Posted on 2014-03-10
1
Medium Priority
?
1,143 Views
Last Modified: 2014-03-11
1. I have a front page template

http://www.coralixthemes.com/themeforest/html/medical/template/index.html

If you click on "Make an appointment now", without entering anything in the fields, the fields get validated. It's done by calling "index1-validation.js".

That form is not a server side form. Doesn't have "runat=server"

2. I took that page and changed that section by adding an ASP.Net login control.

     http://arms.staging.firehost.com/default2.aspx

    That login is a server side control.
   
  <form class="col-md-7 col-lg-6"  runat="server" id="frmLogin"  action="/">

Open in new window


   I changed "index1-validation.js" to this

 
 $().ready(function() {

	// validate signup form on keyup and submit
	$("#frmLogin").validate({
		rules: {
			Login1$UserName: "required",
			.......
		},
		messages: {
			Login1$UserName: "Please enter your fullname",
			......		}
	});
});

Open in new window



Now, when I click on "submit", I want to do validation first but it calls the server (I don't have code behind the submit yet, you'll get page not displayed)

I think I need to do something like this
http://encosia.com/using-jquery-validation-with-asp-net-webforms/

First, make sure the form is valid, set isValid variable. If not valid, prevent the form from being submitted.

I don't know if that's correct and if so, where all this would go?
0
Comment
Question by:Camillia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 39920166
Try changing your jquery to the following to prevent the form submitting:
$().ready(function() {

	// validate signup form on keyup and submit
	$("#frmLogin").validate({
		rules: {
			Login1$UserName: "required",
			.......
		},
		messages: {
			Login1$UserName: "Please enter your fullname",
			......		}
	});
    $("#frmLogin").on('submit', function(e){
        var isValid=$("#frmLogin").valid();
        if(!isValid)
        {
            // prevent postback
            e.preventDefault();
        }
    });
});

Open in new window

0

Featured Post

Amazon Web Services EC2 Cheat Sheet

AWS EC2 is a core part of AWS’s cloud platform, allowing users to spin up virtual machines for a variety of tasks; however, EC2’s offerings can be overwhelming. Learn the basics with our new AWS cheat sheet – this time on EC2!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question