Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 155 Vote(s) - 3.66 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Jquery form submission not working by using right syntax

#1
While giving input type button giving action absolutely correct and submitting the form by jquery or jscript, my form is not submitting. Is there any way to solve this problem?

my code is:

$(document).ready(function(){
$(".sumbitbtn").click(function(e) {

var regEmail = new RegExp(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/);
var selection = document.myfrm.user_type;
var lawfirm_name = $('#lawfirm_name').val();
var first_name = $('#first_name').val();
var last_name = $('#last_name').val();
var mobile_no = $('#mobile_no').val();
var email_id = $('#email_id').val();
var practice_area = $('#practice_area').val();
var cvalue = $('#authentication').val();


var arr_msg = Array();
var count = arr_msg.length;
var alreadyFocussed = false;
//alert(time1);
//alert(start_date);
if(selection[1].checked == true)
{
if(lawfirm_name=='')
{
$("#error_lawfirm_name").html('Please enter Lawfirm Name!');

if(!alreadyFocussed){
$('#lawfirm_name').focus();
alreadyFocussed = true;
}
count++;
}else{
$("#error_lawfirm_name").html("");
}
if(!$("#lawfirm_name").val() == "")
{
if(!NotNumeric($("#lawfirm_name").val()))
{
$("#error_lawfirm_name").html("Please Enter only character.");
if(!alreadyFocussed){
$('#lawfirm_name').focus();
alreadyFocussed = true;
}
count++;
}
else
{
$("#error_lawfirm_name").html("");
}
}
if(!$("#lawfirm_name").val() == "")
{
var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

for (var i = 0; i < document.getElementById("lawfirm_name").value.length; i++)
{
if (iChars.indexOf(document.getElementById("lawfirm_name").value.charAt(i)) != -1)
{
$("#error_lawfirm_name").html("Your name has special characters. \nThese are not allowed.\n Please remove them and try again.");
if(!alreadyFocussed){
$('#lawfirm_name').focus();
alreadyFocussed = true;
}
count++;
}
else
{
//$("#error_lawfirm_name").html("");
}
}

}
}
if(first_name=='')
{
$("#error_first_name").html('Please enter First Name!');

if(!alreadyFocussed){
$('#first_name').focus();
alreadyFocussed = true;
}
count++;
}else{
$("#error_first_name").html("");
}
if(!$("#first_name").val() == "")
{
if(!NotNumeric($("#first_name").val()))
{
$("#error_first_name").html("Please Enter only character.");
if(!alreadyFocussed){
$('#first_name').focus();
alreadyFocussed = true;
}
count++;
}
else
{
$("#error_first_name").html("");
}
}
if(!$("#first_name").val() == "")
{
var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

for (var i = 0; i < document.getElementById("first_name").value.length; i++)
{
if (iChars.indexOf(document.getElementById("first_name").value.charAt(i)) != -1)
{
$("#error_first_name").html("Your name has special characters. \nThese are not allowed.\n Please remove them and try again.");
if(!alreadyFocussed){
$('#first_name').focus();
alreadyFocussed = true;
}
count++;
}
else
{
//$("#error_first_name").html("");
}
}

}
if(last_name=='')
{
$("#error_last_name").html('Please enter last Name!');

if(!alreadyFocussed){
$('#last_name').focus();
alreadyFocussed = true;
}
count++;
}else{
$("#error_last_name").html("");
}
if(!$("#last_name").val() == "")
{
if(!NotNumeric($("#last_name").val()))
{
$("#error_last_name").html("Please Enter only character.");
if(!alreadyFocussed){
$('#last_name').focus();
alreadyFocussed = true;
}
count++;
}
else
{
$("#error_last_name").html("");
}
}
if(!$("#last_name").val() == "")
{
var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

for (var i = 0; i < document.getElementById("last_name").value.length; i++)
{
if (iChars.indexOf(document.getElementById("last_name").value.charAt(i)) != -1)
{
$("#error_last_name").html("Your name has special characters. \nThese are not allowed.\n Please remove them and try again.");
if(!alreadyFocussed){
$('#last_name').focus();
alreadyFocussed = true;
}
count++;
}
else
{
//$("#error_last_name").html("");
}
}

}

if(mobile_no=='')
{
$("#error_mobile_no").html('Please enter mobile number!');

if(!alreadyFocussed){
$('#mobile_no').focus();
alreadyFocussed = true;
}
count++;
}else{
$("#error_mobile_no").html("");
}
if(mobile_no!='')
{
if(mobile_no.length < 10)
{
$("#error_mobile_no").html('Please enter 10 digit mobile number!');
if(!alreadyFocussed){
$('#mobile_no').focus();
alreadyFocussed = true;
}
count++;
}else{
$("#error_mobile_no").html("");
}
}

if(email_id=='')
{
$("#error_email").html('Please enter email!');

if(!alreadyFocussed){
$('#email_id').focus();
alreadyFocussed = true;
}
count++;
}else {
$("#error_email").html("");
}
if(email_id!=''){
if(!regEmail.test(email_id)){
$("#error_email").html('Please enter a valid email.');
if(!alreadyFocussed){
$('#email_id').focus();
alreadyFocussed = true;
}
count++;
}else {
$("#error_email").html('');
}
}


if(selection[0].checked == true)
{

if(practice_area=='')
{
$("#error_practice_area").html('Please enter area of practice!');
if(!alreadyFocussed){
$('#practice_area').focus();
alreadyFocussed = true;
}
count++;
}else {
$("#error_practice_area").html('');
}
}
else {
$("#error_practice_area").html('');
}
if($("#country").val()=='')
{
$("#error_country").html('Please select country!');

if(!alreadyFocussed){
$('#country').focus();
alreadyFocussed = true;
}
count++;
}else {
$("#error_country").hide();
}

if($("#state").val()=='')
{
$("#error_state").html('Please enter town!');

if(!alreadyFocussed){
$('#state').focus();
alreadyFocussed = true;
}
count++;
}else {
$("#error_state").hide();
}
if(!$("#state").val() == "")
{
if(Numeric($("#state").val()))
{
$("#error_state").html("Please Enter only character.");
if(!alreadyFocussed){
$('#state').focus();
alreadyFocussed = true;
}
count++;
}
else
{
$("#error_state").html("");
}
}
if($("#district").val()=='')
{
$("#error_district").html('Please enter city!');

if(!alreadyFocussed){
$('#district').focus();
alreadyFocussed = true;
}
count++;
}else {
$("#error_district").hide();
}
if(!$("#district").val() == "")
{
if(Numeric($("#district").val()))
{
$("#error_district").html("Please Enter only character.");
if(!alreadyFocussed){
$('#district').focus();
alreadyFocussed = true;
}
count++;
}
else
{
$("#error_district").html("");
}
}
if($("#pincode").val()=='')
{
$("#error_pincode").html('Please enter pincode!');

if(!alreadyFocussed){
$('#pincode').focus();
alreadyFocussed = true;
}
count++;
}else {
$("#error_pincode").hide();
}
/*if(cvalue=='')
{
document.getElementById('error_authentication').innerHTML='Please enter security code!';

if(!alreadyFocussed){
document.getElementById('authentication').focus();
alreadyFocussed = true;
}
count++;
}
else{
document.getElementById('error_authentication').innerHTML="";
}
if(cvalue!='')
{
var securitycode = document.getElementById('scode').value;
if(securitycode==0)
{
document.getElementById('error_authentication').innerHTML='Please enter correct security code!';
if(!alreadyFocussed){
document.getElementById('authentication').focus();
alreadyFocussed = true;
}
count++;
}
else{
document.getElementById('error_authentication').innerHTML="";
}
}*/

if(count == 0){
$('#myfrm').submit();
if(cvalue!='')
{
document.getElementById('error_authentication').innerHTML="";
$.post("<?php echo APP_ROOT_URL; ?>checkcode.php", { val: cvalue }, function(data) {

if(data == "0")
{
document.getElementById('error_authentication').innerHTML='Please enter correct security code!';
if(!alreadyFocussed){
document.getElementById('authentication').focus();
alreadyFocussed = true;
}
sleep(10);
return false;
}
else
{
$("#error_authentication").text('');


}
});
//return false;
alert(document.getElementById('error_authentication').innerHTML);
if(document.getElementById('error_authentication').innerHTML == '') { alert('testing true'); document.getElementById('myfrm').submit(); } else { alert('testing false'); return false; }
}
else
{
document.getElementById('error_authentication').innerHTML='Please enter security code!';
if(!alreadyFocussed){
document.getElementById('authentication').focus();
alreadyFocussed = true;
}
return false;
}

//return true;
}else{
return false;
}
});
});

function checkcode(valuecode)
{
var dataString = 'val='+valuecode;
$.ajax({
type: "GET",
url: "<?php echo APP_ROOT_URL; ?>checkcode.php",
data: dataString,
cache: false,
success: function(value1)
{
document.getElementById('scode').value=value1;
if(value1=='0')
{
//alert('Please enter correct security code!');
document.getElementById('error`enter code here`_authentication').innerHTML='Please enter correct security code!';
document.getElementById('authentication').focus();
return false;
}else{
document.getElementById('error_authentication').innerHTML="";
}
}
});

html part

<form name="myfrm" id="myfrm" enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="button" id="mynewid" name="submit" value="Submit" class="sumbitbtn" /></div>
</form>



Please check and help me out. Thanks in advance
Reply

#2
Use the following steps to debug:

* sleep(10) is a syntax error in JavaScript; `setTimeout(function(){},1000)` is more like it
* Use [FireQuery](

[To see links please register here]

) to debug jQuery
* Use [EventBug](

[To see links please register here]

) to debug event handlers
* Use [FirePHP](

[To see links please register here]

) to debug AJAX requests
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through