Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- $('#sub').click(function(e) {
- var fname = $('#fname').val();
- var lname = $('#lname').val();
- var email = $('#email').val();
- var age = $('#age').val();
- var username = $('#Username').val();
- var Password = $('#Password').val();
- var CPassword = $('#CPassword').val();
- var username_flag = false;
- var name_regex = /^[a-zA-Z]+$/;
- var email_regex = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
- //var add_regex = /^[0-9a-zA-Z]+$/;
- $("#Username").blur(function() {
- $.ajax({
- url: "./display.php",
- data:'Username='+$("#Username").val(),
- type: "POST",
- success:function(data){
- console.log(data);
- if(data == "true"){
- $("#user-availability-status").html("not avilable");
- username_flag = true;
- }
- else{
- username_flag = false;
- $("#user-availability-status").html("avilable");
- }
- },
- });
- });
- if (fname.length == 0) {
- $('#head').text("* All fields are mandatory *");
- $("#fname").focus();
- return false;
- }
- else if (!fname.match(name_regex) || fname.length == 0) {
- $('#p1').text("For your first name please use alphabets only ");
- $("#fname").focus();
- return false;
- }
- else if (!lname.match(name_regex) || lname.length == 0) {
- $('#p2').text(" For your last name please use alphabets only");
- $("#lname").focus();
- return false;
- }
- else if (!email.match(email_regex) || email.length == 0) {
- $('#p3').text("Please enter a valid email address");
- $("#email").focus();
- return false;
- }
- else if (isNaN(age)||age<1||age>100){
- $('#p4').text("Please enter a valid age");
- $("#age").focus();
- return false;
- }
- else if ((!(username.length >= 6 ) || username.length == 0) && username_flag == true ) {
- $('#p5').text(" Please enter above 6 characters and username avilable");
- $("#username").focus();
- return false;
- }
- else if(!(Password.length >=6) || Password.length ==0){
- $('#p6').text("Please enter above 6 characters");
- $("#Password").focus();
- return false;
- }
- else if(Password!=CPassword){
- $('#p7').text("password do not match");
- $("#Password").focus();
- return false;
- }
- else {
- $.ajax({
- type :"POST",
- url :"insert.php",
- data: datastring,
- cache: false,
- success: function(result){
- alert(result);
- }
- });
- // alert("Form Submitted Successfuly!");
- // return true;
- }
- });
- });
Add Comment
Please, Sign In to add comment