Hi, I am working on design a blog and I want to do user input validation before their data is post on database, but I find it difficult to get the value for test in if statement, I tried to console.log each jQuerry variable but am getting empty string. someone should help please!!!
$(document).ready(function() {
var $name = $('#fullname');
var $email = $('#regEmail');
var $password = $('#regPwrd');
var $reapeatPassword = $('repeatPwrd');
var $login = $('loginMail');
$name = $name.val();
$email = $email.val();
$password = $password.val();
$.ajax({
type: 'GET',
url: 'http://localhost:3000',
success: function(){
}
});
$('#signUp').on('click', function() {
//I must Validate form Here
var $details = {
name: $name,
email: $email,
password: $password
};
$.ajax({
type: 'POST',
url: 'http://localhost:3000/posts',
data: $details,
success: function(newUser) {
alert($name);
}
});
console.log($details);
});
});