Jquery error slow down - php

I'm having a problem with my Jquery register validation.
I've a problem getting the error message back if you don't fill in a name.
jQuery(document).ready(function () {
$('#register').submit(function () {
var action = $(this).attr('action');
var error = '<div class=\"states\"><li class=\"warning\"><strong>Fout!</strong><br /> U hebt geen naam opgegeven.</li> <br /></ul>';
$(".states li").slideUp(750, function () {
$('.states li').hide();
$('#submit')
.after('<img src="images/ajax-loader.gif" class="loader" />')
.attr('disabled', 'disabled');
$.post(action, {
name: $('#name').val(),
realname: $('#realnam').val(),
pass: $('#pass').val(),
repeatpass: $('#repeatpass').val(),
mail: $('#mail').val(),
mailadres: $('#mailadres').val(),
});
if (name == "") {
$(error).slideDown('slow');
}
});
return false;
});
});
And my HTML code:
<script src="js/aanmelden.js"></script>
<?php
include_once 'include/config.php';
?>
<div class="text-section">
<h1>Aanmelden</h1>
<p>Hier kunt u zich <strong>gratis</strong> aanmelden op <?php echo $sNaam; ?></p>
</div>
<div class="states">
<li class="warning"><strong>Waarschuwing</strong> Deze pagina is (nog) niet af, hier wordt aangewerkt.</li> <br />
</ul>
<form method="POST" action="bin/register.php" id="register">
<fieldset>
<legend>Naam</legend>
<label id="username">Gebruikersnaam:</label>
<input type="text" class="text" name="gebruikersnaam" id="name" placeholder="Uw gebruikersnaam" /> <br />
<label id="realname">Uw echte naam:</label>
<input type="text" class="text" name="echtenaam" id="realnam" placeholder="Uw echte naam" /> <br />
</fieldset>
<fieldset>
<legend>Wachtwoord</legend>
<label id="password">Uw wachtwoord:</label>
<input type="password" class="text" id="pass" name="wachtwoord" placeholder="Uw wachtwoord" /> <br />
<label id="repeatpassword">Uw wachtwoord nogmaals:</label>
<input type="password" class="text" id="repeatpass" name="hwachtwoord" placeholder="Uw wachtwoord nogmaals" /> <br />
</fieldset>
<fieldset>
<legend>Mail</legend>
<label id="mailadres">Uw mail adres:</label>
<input type="text" class="text" name="mail" id="mail" placeholder="Uw mail adres" /> <br />
<label id="repeatmail">Uw mail adres nogmaals:</label>
<input type="text" class="text" name="hmail" id="mailadres" placeholder="Uw mail adres nogmaals" /> <br />``
</fieldset>
<input type="submit" name="submit" value="Registreren" class="orange" id="submit" />
<br />
</form>
My problem(demo at http://mijnrpg.eu and then the second tab). If you click on the button where it says "Registreren", you will see what I mean. It isn't giving an error.

$.post(action, {
name: $('#name').val(),
realname: $('#realnam').val(),
pass: $('#pass').val(),
repeatpass: $('#repeatpass').val(),
mail: $('#mail').val(),
mailadres: $('#mailadres').val(),
});
use serialize
$('#register').serialize();
your post function would be
$.post(action,
$('#register').serialize(),
function(resp)
{
///
}
);
And to answer your question try
$('#name').val()==''
Here i slightly modified your code http://jsfiddle.net/eVA8s/10/
So basically what you want to do is create div tag with id error-message and set it style to hidden,
second watch at your tags you have too many useless tags,
third always use firebug in firefox, or press f12 in chrome.

you need to validate first not last. updated
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
$('.error').hide('fast');
$('.warning').hide('fast');
$('.succes').hide('fast');
$('#register').submit(function () {
if ($('#name').val() == "")
{
$('.error').slideDown('slow'); return false;
}
else
{
var action = $(this).attr('action');
$(".states li").slideUp(750, function () {
$('.states li').hide();
$('#submit')
.after('<img src="images/ajax-loader.gif" class="loader" />')
.attr('disabled', 'disabled');
$.post(action, {
name: $('#name').val(),
realname: $('#realnam').val(),
pass: $('#pass').val(),
repeatpass: $('#repeatpass').val(),
mail: $('#mail').val(),
mailadres: $('#mailadres').val(),
});
});
return false;
}
});
});
</script>
<div class="text-section">
<h1>Aanmelden</h1>
<p>Hier kunt u zich <strong>gratis</strong> aanmelden op <?php echo $sNaam; ?></p>
</div>
<div class="states">
<ul class="states">
<li class="error"><strong>Fout</strong> Dit zullen ze zien wanneer ze iets fout hebben gedaan.</li>
<br />
<li class="warning"><strong>Waarschuwing</strong> Dit zullen ze zien wanneer er een onbekende fout is opgetreden.</li>
<br />
<li class="succes"><strong>Goed</strong> Dit zullen ze zien wanneer iets succesvol gegaan is.</li>
</ul>
</div>
<form method="POST" action="bin/register.php" id="register">
<fieldset>
<legend>Naam</legend>
<label id="username">Gebruikersnaam:</label>
<input type="text" class="text" name="gebruikersnaam" id="name" placeholder="Uw gebruikersnaam" /> <br />
<label id="realname">Uw echte naam:</label>
<input type="text" class="text" name="echtenaam" id="realnam" placeholder="Uw echte naam" /> <br />
</fieldset>
<fieldset>
<legend>Wachtwoord</legend>
<label id="password">Uw wachtwoord:</label>
<input type="password" class="text" id="pass" name="wachtwoord" placeholder="Uw wachtwoord" /> <br />
<label id="repeatpassword">Uw wachtwoord nogmaals:</label>
<input type="password" class="text" id="repeatpass" name="hwachtwoord" placeholder="Uw wachtwoord nogmaals" /> <br />
</fieldset>
<fieldset>
<legend>Mail</legend>
<label id="mailadres">Uw mail adres:</label>
<input type="text" class="text" name="mail" id="mail" placeholder="Uw mail adres" /> <br />
<label id="repeatmail">Uw mail adres nogmaals:</label>
<input type="text" class="text" name="hmail" id="mailadres" placeholder="Uw mail adres nogmaals" /> <br />``
</fieldset>
<input type="submit" name="submit" value="Registreren" class="orange" id="submit" />
<br />
</form>
demo link

Related

Multi-fields form with image input

I have a form like this and I would like to know if there is a way to add an image input and upload it to the server.
I would like to be able to upload images to [ROOT]/upload_img/ but, to be honest I don't know how to do it and most of the code parts I found don't work with mine...
Se here I am.
Here's my code :
<html>
<head></head>
<body>
<div id="main">
<div id="login">
<form action="" method="post">
<label>Titre de l'annonce :</label>
<input type="text" name="i_title" id="name" required="required" placeholder=""/>
<br />
<br />
<label>Adresse : </label>
<input type="text" name="i_adress" id="email" required="required" placeholder=""/>
<br/>
<br />
<label>Ville :</label>
<input type="text" name="i_city" id="city" required="required" placeholder="Please Enter Your City"/>
<br/>
<br />
<label>Surface du logement entier :</label>
<input type="text" name="i_surf_room" id="surf_room" required="required" placeholder=""/> En m2
<br/>
<br />
<label>Surface de la chambre :</label>
<input type="text" name="i_surf_home" id="surf_home" required="required" placeholder=""/>
<br/>
<br />
<label>Description :</label>
<input type="text" name="i_description" id="description" required="required" placeholder=""/>
<br/>
<br />
<label>Date de début de disponibilité :</label>
<input type="month" name="i_start_date" id="start_date" required="required" placeholder=""/>
<br/>
<br />
<label>Date de fin de disponibilité :</label>
<input type="month" name="i_end_date" id="end_date" required="required" placeholder=""/>
<br/>
<br />
<label>Photographies du logement</label>
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="reset"> -
<input type="submit" name="submit"/>
<br />
</form>
</div>
</div>
<?php
if(isset($_POST["submit"])) {
$hostname='xxxx';
$username='xxxx';
$password='xxx';
try {
$dbh = new PDO("mysql:host=$hostname;dbname=xxxx",$username,$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
$sql = "INSERT INTO students (title, adress, city, surf_home, surf_room, description, start_date, end_date)
VALUES ('".$_POST["i_title"]."','".$_POST["i_adress"]."','".$_POST["i_city"]."','".$_POST["i_surf_home"]."','".$_POST["i_surf_room"]."','".$_POST["i_description"]."','".$_POST["i_start_date"]."','".$_POST["i_end_date"]."')";
if ($dbh->query($sql)) {
echo "
<script type= 'text/javascript'>alert('New Record Inserted Successfully');</script>";
} else {
echo "
<script type= 'text/javascript'>alert('Data not successfully Inserted.');</script>";
}
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>
</body>
</html>

Application form with phpMyAdmin database

So now I'm trying to make a application form for a trial drive lesson. I'm new at PHP, so I tried to take some code from my registration form that is working fully.
But nothing happens when i click submit(aanvraag_btn)
Here is the code:
<form class ="myform" action="index.php" method="post" >
<h3 class="center"> Vraag een proefrit aan! </h3>
<br></br>
<input name="naam" type="text" class="inputvalues" placeholder="Naam" required />
<br></br>
<input name="email" type="text" class="inputvalues" placeholder="Email"/>
<br></br>
<input name="Telefoonnummer" type="text" class="inputvalues" placeholder="Telefoonnummer" required />
<br></br>
<input name="aanvraag" type="button" id="aanvraag_btn" value="Aanvragen" required/> <br>
This is the PHP:
<?php
if(isset($_POST['aanvraag']))
{
$naam = $_POST['naam'];
$email = $_POST['email'];
$telefoonnummer = $_POST['telefoonnummer'];
$query= "insert into user values('$naam','$email','telefoonnummer')";
$query_run = mysqli_query($con,$query);
if($query_run)
{
echo '<script type="text/javascript"> alert ("Bedankt voor de aanvraag, we nemen zo snel mogelijk contact op.") </script>';
}
else {
echo '<script type="text/javascript"> alert ("Error>';
}
}
?>
Use type="submit"
<input name="aanvraag" type="submit" id="aanvraag_btn" value="Aanvragen" required/>
Try with this:
<form class ="myform" action="index.php" method="post" >
<h3 class="center"> Vraag een proefrit aan! </h3>
<br></br>
<input name="naam" type="text" class="inputvalues" placeholder="Naam" required />
<br></br>
<input name="email" type="text" class="inputvalues" placeholder="Email"/>
<br></br>
<input name="Telefoonnummer" type="text" class="inputvalues" placeholder="Telefoonnummer" required />
<br></br>
<input name="aanvraag" type="submit" id="aanvraag_btn" value="Aanvragen"/> <br>
</form>
1)Missing form close
2)missing type ="submit"
3)typo in element attribute near name="telefoonnummer"
<?php
if(isset($_POST['aanvraag']))
{
$naam = $_POST['naam'];
$email = $_POST['email'];
$telefoonnummer = $_POST['telefoonnummer'];
$query= "insert into user values('$naam','$email','telefoonnummer')";
$query_run = mysqli_query($con,$query);
if($query_run)
{
echo '<script type="text/javascript"> alert ("Bedankt voor de aanvraag, we nemen zo snel mogelijk contact op.") </script>';
}
else {
echo '<script type="text/javascript"> alert ("Error");</script>';
}
}
?>
<form class ="myform" action="index.php" method="post" >
<h3 class="center"> Vraag een proefrit aan! </h3>
<br></br>
<input name="naam" type="text" class="inputvalues" placeholder="Naam" required />
<br></br>
<input name="email" type="text" class="inputvalues" placeholder="Email"/>
<br></br>
<input name="Telefoonnummer" type="text" class="inputvalues" placeholder="Telefoonnummer" required />
<br></br>
<input name="aanvraag" type="submit" id="aanvraag_btn" value="Aanvragen"/> <br>
</form>

AJAX not working submitting form

I got some AJAX code, but it doesn't get response from server. I tried many things but can't figure out why this is not working. I am running on a localhost setup with XAMPP. I want the echo to be seen in the span with id status.
AJAX on index.php
$(document).ready(function() {
$("#registrationform").submit(function() {
$.ajax({
type: "POST",
url: "registration.php",
data: $("#registrationform").serialize(),
success: function(data) {
$("#status").html(data);
}
});
alert("Ajax not running")
});
});
FORM on index.php
<form id="registrationform" action="">
Voornaam: <input type="text" name="voornaam" /><br />
Tussenvoegsel: <input type="text" name="tussenvoegsel" /><br />
Achternaam: <input type="text" name="achternaam" /><br />
Geslacht: <?php include_once("parser/geslacht.php"); ?><br />
Land: <?php include_once("parser/land.php"); ?><br />
Geboortedatum: <?php include_once("parser/gebdatum.php"); ?><br />
E-mail: <input type="text" name="e-mail" /><br />
Wachtwoord: <input type="password" name="password" /><br />
Hertype wachtwoord: <input type="password" name="password2" /><br /><br />
De onderstaande vraag is nodig om uw wachtwoord terug te halen mocht u die vergeten zijn.<br />
Geheime vraag: <select name="geheimevraag" id="geheimevraag">
<option value="huisdier">Wat is de naam van jouw eerste huisdier?</option>
<option value="moedername">Wat is de meisjesnaam van je moeder?</option>
<option value="eerstebaas">Hoe heet je eerste baas?</option>
<option value="eigenvraag">Eigen vraag opstellen</option>
</select><br/>
<span id="anders" style="display:none;">Eigen vraag: <input type="text" name="eigen_vraag" style="width:300px;"/></span><br />
Antwoord: <input type="password" name="gantwoord" /><br />
</form>
<input type="submit" value="Submit"/>
<span id="status"></span>
registration.php
if(!empty($_POST)){
echo "There is a value";
}else{
echo "enter a value";
}
?>
write the <input type="submit" value="Submit"/> before </form> close tag
<form id="registrationform" action="">
Voornaam: <input type="text" name="voornaam" /><br />
Tussenvoegsel: <input type="text" name="tussenvoegsel" /><br />
Achternaam: <input type="text" name="achternaam" /><br />
Geslacht: <?php //include_once("parser/geslacht.php"); ?><br />
Land: <?php //include_once("parser/land.php"); ?><br />
Geboortedatum: <?php //include_once("parser/gebdatum.php"); ?><br />
E-mail: <input type="text" name="e-mail" /><br />
Wachtwoord: <input type="password" name="password" /><br />
Hertype wachtwoord: <input type="password" name="password2" /><br /><br />
De onderstaande vraag is nodig om uw wachtwoord terug te halen mocht u die vergeten zijn.<br />
Geheime vraag: <select name="geheimevraag" id="geheimevraag">
<option value="huisdier">Wat is de naam van jouw eerste huisdier?</option>
<option value="moedername">Wat is de meisjesnaam van je moeder?</option>
<option value="eerstebaas">Hoe heet je eerste baas?</option>
<option value="eigenvraag">Eigen vraag opstellen</option>
</select><br/>
<span id="anders" style="display:none;">Eigen vraag: <input type="text" name="eigen_vraag" style="width:300px;"/></span><br />
Antwoord: <input type="password" name="gantwoord" /><br />
<input type="submit" value="Submit"/>
</form>
<span id="status"></span>
Your jquery script script:
<script>
$(document).ready(function() {
$("#registrationform").submit(function(ev){
ev.preventDefault();
$.ajax ({
type: "POST",
url: "registration.php",
data: $("#registrationform").serialize(),
success: function(data) {
$("#status").html(data);
}
});
alert("Ajax not running")
});
});
</script>
Please try this code
$(document).ready(function() {
$("#registrationform").submit(function(e){
e.preventDefault();
$.ajax({
type: "POST",
url: "registration.php",
data: $("#registrationform").serialize(),
success: function(data) {
$("#status").html(data);
}
});
alert("Ajax not running")
});
});
You have to prevent the default behavior of the submit button
$("#registrationform").submit(function(ev) {
ev.preventDefault();
...
Then you need to implement a proper failure handler, your current one will allways alert because that ajax is async
$.ajax({
type: "POST",
url: "registration.php",
data: $("#registrationform").serialize(),
success: function(data) {
console.log(data); // check your console to see if request is success and what it contains
$("#status").html(data);
}
}).fail(function () {
alert("oh noes");
});
You need to prevent the default behavior of the form so that the page won't change location, and so that JS can do the AJAX request.
$("#registrationform").submit(function(e) {
e.preventDefault(); //this one
$.ajax({
type: "POST",
url: "registration.php",
data: $("#registrationform").serialize(),
success: function(data) {
$("#status").html(data);
}
});
});

Form submit not posting Safari

I've got a registration form setup which works fine on all browsers...except Safari.
I thought it should be a problem that deals with Javascript, as it mostly is. But after I turned Javascript off in Safari, there's still no data being posted.
The form is live on:
http://tpgrf.nl/testserver/alpha/account/registreer/
I've added this text on top of the page, for testing, to make sure if data has been posted or not.
if($_SERVER['REQUEST_METHOD'] == 'POST'){
echo 'post';
}else{
echo 'niets gepost';
}
Any thoughts where to look for the answer?
EDIT: Here's the form (output HTML)
<form name="registerform" id="registerform" action="http://tpgrf.nl/testserver/alpha/account/registreer/" method="post">
<script type="text/javascript">
jQuery(document).ready(function($) {
//Since we want users to login with there email; there's no need to also register a username. Therefore the username field = email field
$("#user_login").live('change', function(){
$('#user_email').val($("#user_login").val());
});
//Display fields, depending on the selected role
$('#role').live('change', function(){
if($('#role').val() === 'docent'){
$('#messageRegisterDocent').show();
$('#pKlas').hide();
}else{
$('#messageRegisterDocent').hide();
$('#pKlas').show();
}
});
//The json call to automcplete School
var ajaxurl = 'http://tpgrf.nl/testserver/alpha/wp-admin/admin-ajax.php';
$("#school").autocomplete({
delay: 0,
minLength: 1,
source: function(req, response){
$.getJSON('http://tpgrf.nl/testserver/alpha/wp-admin/admin-ajax.php?callback=?&action=school_autocomplete', req, response);
},
select: function(event, ui){
$('#school').val(ui.item.label);
$('#school_id').val(ui.item.school_id);
}
});
});
</script>
<p>
<input type="hidden" name="user_email" id="user_email" class="input" value="" size="20" />
<p>
<label for="user_login">E-mail</label>
<input type="email" name="user_login" id="user_login" class="input" value="" size="20" />
</p>
<p>
<label>Voornaam</label>
<input id="first_name" type="text" size="25" value="" name="first_name" />
</p>
<p>
<label>Achternaam</label>
<input id="last_name" type="text" size="25" value="" name="last_name" />
</p>
<p>
<label>Ik ben...</label>
<select name="role" id="role">
<option value="">...selecteer</option>
<option value="leerling" >Leerling</option>
<option value="docent" >Docent</option>
</select>
<p class="message" id="messageRegisterDocent" style="display:none;"><strong>Let op:</strong> registreer met uw e-mailadres van de school waar u werkzaam bent. <br />Voor een aantal functies vindt namelijk handmatige autorisatie plaats; dit is niet mogelijk met een privé e-mailadres.</p>
</p>
<p>
<label>Mijn school</label>
<input type="text" id="school" class="autoComplete" size="25" value="" name="school" />
<input type="hidden" id="school_id" name="school_id" value="">
</p>
<p id="pKlas"style="display:none;">
<label>Mijn klas</label>
<input type="text" id="klas" size="25" value="" name="klas" />
</p>
<p id="reg_passmail">U zult een wachtwoord per e-mail ontvangen.</p>
<p class="submit">
<input type="submit" name="wp-submit" id="wp-submit" value="Registratie" />
of Ik heb al een account...
<input type="hidden" name="redirect_to" value="/testserver/alpha/account/login/?checkemail=registered" />
<input type="hidden" name="instance" value="" />
</p>
</form>
Your problem might be caused by the following line of code:
<input type="submit" name="wp-submit" id="wp-submit" value="Registratie" />
You wrap the submit button tag inside an 'a' tag which is pointing to an empty URL and causes a link to the current page only. It might be that Safari does not parse this wrapped button well, and instead prefers the A link over the submit button.
Unwrapping the 'input' tag and changing the code to:
<input type="submit" name="wp-submit" id="wp-submit" value="Registratie" />
might work.

Ajax+PHP form needs 2 clicks to be submited

Here is my code:
<script type="text/javascript">
jQuery(document).ready(function(){
// binds form submission and fields to the validation engine
jQuery("#formIDRegister").validationEngine(); //--> this is the jQuery Validation Engine. The code below has no relation with it.
});
function func(){
$(document).ready(function() {
$(document).ajaxStop($.unblockUI);
$("#formIDRegister").submit(function() {
$("input[type=submit]").attr("disabled", "disabled");
$.blockUI({message: '<h1><img src="./images/misc/ajax-loader.gif" /> Espere um momento...</h1>'});
var trueName = $("#trueName").val();
var trueSurname = $("#trueSurname").val();
var phoneHomeCountryId = $("#phoneHomeCountryId").val();
var phoneHomeCityId = $("#phoneHomeCityId").val();
var phoneHome = $("#phoneHome").val();
var phoneCellCountryId = $("#phoneCellCountryId").val();
var phoneCellCityId = $("#phoneCellCityId").val();
var phoneCell = $("#phoneCell").val();
var userCpf = $("#userCpf").val();
var userBirth = $("#userBirth").val();
var userAddressCountry = $("#userAddressCountry").val();
var userAddressState = $("#userAddressState").val();
var userAddressCity = $("#userAddressCity").val();
var userAddressStreet = $("#userAddressStreet").val();
var userAddressNumber = $("#userAddressNumber").val();
var userAddressCompl = $("#userAddressCompl").val();
var userAddressDistrict = $("#userAddressDistrict").val();
$.post('./cadastro/processa/identificacao', {trueName:trueName, trueSurname:trueSurname, phoneHome:phoneHome, phoneHomeCountryId:phoneHomeCountryId, phoneHomeCityId:phoneHomeCityId, phoneCell:phoneCell,phoneCellCountryId:phoneCellCountryId, phoneCellCityId:phoneCellCityId, userCpf:userCpf, userBirth:userBirth, userAddressCountry:userAddressCountry, userAddressState:userAddressState, userAddressCity:userAddressCity, userAddressStreet:userAddressStreet, userAddressNumber:userAddressNumber, userAddressCompl:userAddressCompl, userAddressDistrict:userAddressDistrict, },
function(resposta) {
$("#ErrorBarContent1").hide();
$("#ErrorBarContent2").hide();
$("#ErrorBarContent3").hide();
$("input[type=submit]").removeAttr("disabled");
if (resposta != false) {
if(resposta == "11"){
$("#ErrorBarContent1").show();
}
if(resposta == "12"){
$("#ErrorBarContent2").show();
}
if(resposta == "1"){
$("#ErrorBarContent3").show();
}
} else {
location.href ="cadastro/caracteristicas-gerais/";
}
});
return false;
});
});
}
</script>
Here is the HTML
<form id="formIDRegister" class="" method="post" action="javascript:func()" accept-charset="UTF-8">
<div id="ErrorBarContent1" onclick="$(this).fadeOut('slow');" style="display:none;"><div class="yellowErrorBar">Todos os campos devem ser preenchidos</div></div>
<div id="ErrorBarContent2" onclick="$(this).fadeOut('slow');" style="display:none;"><div class="yellowErrorBar">Cpf já está sendo utilizado por outro usuário.</div></div>
<div id="ErrorBarContent3" onclick="$(this).fadeOut('slow');" style="display:none;"><div class="redErrorBar">Opps, ocorreu um erro ao atualizar seu cadastro, nossa equipe já foi avisada. Por favor, tente novamente mais tarde.</div></div>
<!-- name -->
<div class="rowOff" id="name">
<p><i>1.</i> Identificação</p>
<label>
<span class="trueName">Seu(s) nome(s)</span><br />
<input value="" class="validate[required] text-input" type="text" name="trueName" id="trueName" />
</label>
<label>
<span class="trueSurname">e seu(s) sobrenome(s)</span><br />
<input value="" class="validate[required] text-input" type="text" name="trueSurname" id="trueSurname" />
</label>
</div>
<!-- phone -->
<div class="rowOn" id="phone">
<p><i>2.</i> Telefones para contato</p>
<div class="phone1">
<span class="phoneHome">Telefone de contato 1</span><br />
<input onmouseover="tooltip.show('Insira o código de seu país');" onmouseout="tooltip.hide();" value="" class="validate[required,custom[onlyNumberSp]] text-input" type="text" name="phoneHomeCountryId" id="phoneHomeCountryId" maxlength="3" />
<input onmouseover="tooltip.show('Insira o código de área');" onmouseout="tooltip.hide();" value="" class="validate[required,custom[onlyNumberSp]] text-input" type="text" name="phoneHomeCityId" id="phoneHomeCityId" maxlength="2" />
<input value="" class="validate[required,custom[onlyNumberSp]] text-input" type="text" name="phoneHome" id="phoneHome" />
</div>
<br />
<br />
<br />
<div class="phone2">
<span class="phoneCell">Telefone de contato 2</span><br />
<input onmouseover="tooltip.show('Insira o código de seu país');" onmouseout="tooltip.hide();" value="" class="validate[required,custom[onlyNumberSp]] text-input" type="text" name="phoneCellCountryId" id="phoneCellCountryId" maxlength="3" />
<input onmouseover="tooltip.show('Insira o código de área');" onmouseout="tooltip.hide();" value="" class="validate[required,custom[onlyNumberSp]] text-input" type="text" name="phoneCellCityId" id="phoneCellCityId" maxlength="2" />
<input value="" class="validate[required,custom[onlyNumberSp]] text-input" type="text" name="phoneCell" id="phoneCell" />
</div>
<div id="divPhoneInfo">Seu número de telefone não será divulgado. Garantimos o sigilo.</div>
</div>
<!-- cpf -->
<div class="rowOff" id="cpf">
<p><i>3.</i> CPF</p>
<label>
<span class="userCpf">Insira seu CPF </span><br />
<input value="" class="validate[required] text-input" type="text" name="userCpf" id="userCpf" /> <span class="hotspot" onmouseover="tooltip.show('Insira o número de seu CPF de 11 dígitos');" onmouseout="tooltip.hide();"><img src="./images/userInterface/info.png" /></span>
</label>
<div id="divCpfInfo">Insira um número de CPF válido. O uso de números falsos implica no descumprimento dos Termos de Utilização, e estará sujeito às penas da Lei.</div>
</div>
<!-- birth -->
<div class="rowOn" id="birth">
<p><i>4.</i> Data de nascimento</p>
<label>
<span class="userBirth">Insira sua data de nascimento </span><br />
<input value="" class="validate[required] text-input" type="text" name="userBirth" id="userBirth" /> <span class="hotspot" onmouseover="tooltip.show('Você PRECISA ser maior de 18 anos para se cadastrar! O formato é dd/mm/aaaa');" onmouseout="tooltip.hide();"><img src="./images/userInterface/info.png" /></span>
</label>
</div>
<!-- address -->
<div class="rowOff" id="adress">
<p><i>5.</i> Endereço</p>
<label id="pais">
<span class="userAddressCountry">País</span><br />
<select name="userAddressCountry" id="userAddressCountry" class="validate[required]" onchange="buscaEstados(this.value)" /></select>
</label >
<label id="estado" style="display: none">
<span class="userAddressState">Estado</span><br />
<select value="" class="validate[required] text-input" type="text" name="userAddressState" id="userAddressState" onchange="buscaCidades(this.value)"/><option value="">Primeiramente, selecione o pais</option></select>
</label>
<label id="cidade" style="display: none">
<span class="userAddressCity">Cidade</span><br />
<select value="" class="validate[required] text-input" type="text" name="userAddressCity" id="userAddressCity" readonly="readonly" /><option value="">Primeiramente, selecione o pais</option></select>
</label>
<br />
<br />
<br />
<div id="endereco" style="display: none">
<label>
<span class="userAddressStreet">Escreva seu Endereço</span><br />
<input value="" class="validate[required] text-input" type="text" name="userAddressStreet" id="userAddressStreet" />
</label>
<label>
<span class="userAddressNumber">Número</span><br />
<input value="" class="validate[required] text-input" type="text" name="userAddressNumber" id="userAddressNumber" />
</label>
<label>
<span class="userAddressCompl">Complemento</span><br />
<input value="" class="" type="text" name="userAddressCompl" id="userAddressCompl" />
</label>
<label>
<span class="userAddressDistrict">Bairro</span><br />
<input value="" class="validate[required] text-input" type="text" name="userAddressDistrict" id="userAddressDistrict" />
</label>
</div>
</div>
<div id="divAddressInfo">Assim como os números de contato e o CPF, seu endereço estará sob total sigilo. Em seu perfil aparecerão apenas <b>País</b>, <b>Estado</b> e <b>Cidade</b></div>
<!-- submit -->
<div class="rowOn" style="margin-top: 40px; padding-top: 40px;">
<label style="margin-left: 170px;">
<input class="submit" type="submit" value="Enviar e Prosseguir" id="sendButtonRegister" />
</label>
</div>
<!-- /formID4 -->
</form>
When I click in submit, in the first click, nothing happens (actually, the position of the screen goes to its middle). The form is submited only in the second click. What is wrong?
You should not use the $(document).ready(function() into function func()
best of all use the next code
$('#formIDRegister').submit(function(e){
e.preventDefault();
func();//your function
});
this code you can put into $(document).ready function or after your form
also remove action="javascript:func()" attribute from form tag

Categories