I have a jquery sign up form that I would like to convert to .asp values. I would like when a user click submit on the jquery form, for it to do the action of the .asp form. Thanks You.
<script language="javascript" type="text/javascript">// <![CDATA[
function checkit()
{
var stop=0
var msg=""
var valid = 1
var valid2 = 1
var no=0;
if(document.theform.folder.value=="" || document.theform.folder.value=="Folder Name"){stop=1;msg=msg+"\nYou need to input a folder name."}
if(document.theform.password.value==""){stop=1;msg=msg+"\nYou need to enter a password."}
if (document.theform.owneremail.value.indexOf("@") == -1){stop=1;msg=msg+"\nYou need to enter a valid E-mail Address."}
//if every thing looks good...submit it.
if (stop==1){alert(msg);msg="";return false;}
if (stop!=1&&no!=1){document.theform.submit();return true;}
}
// ]]></script>
<!--#include file="domain.txt"--><form action="qry_index1.asp" method="post" name="theform"><!----------------------------------start section 1-------------------------------------------------------><<%'dim arrtmp="Split(Request.ServerVariables("server_name"),">
<!--<font size="1" face="verdana" color="black"><strong>http://</strong></font><input type="text" name="folder" value="Folder Name" size="20" onFocus="javascript:document.theform.folder.value='';"><font size="1" face="verdana" color="black"><b>.<=arrTmp(1)%>.<=arrTmp(2)%>/</b></font>
--> <span size="1" face="verdana" color="black" style="color: black; font-family: verdana; font-size: xx-small;"><b><%=domain%>sites/<!--%=domain%--></b></span><input type="text" name="folder" value="Folder Name" size="20" onfocus="javascript:document.theform.folder.value='';"
/> <!--%'dim-->
<div><span size="1" face="verdana" color="4B4B4B" style="color: #4b4b4b; font-family: verdana; font-size: xx-small;">Once your site is built you will be able to setup a custom domain (.com) name. </span></div>
<hr /><!------------------------------end-------------------------------------------------------><!------------------------------start section 2----------------------------------------------------------><<span size="1" face="verdana" color="black" style="color:
black; font-family: verdana; font-size: xx-small;"><b>Your Password:</b></span><input type="password" name="password" /><span size="1" face="Verdana" color="4B4B4B" style="color: #4b4b4b; font-family: Verdana; font-size: xx-small;">* This password will allow
you to get into your new web sites administration tool. That way you will be able to go back any time to quickly make changes to your site! </span><hr /><!------------------------------end-------------------------------------------------------><!------------------------------start
section 3----------------------------------------------------------><<span size="1" face="verdana" color="black" style="color: black; font-family: verdana; font-size: xx-small;"><b>E-mail Address:</b></span><input name="owneremail" size="30" type="text"
/><hr /><input type="image" src="images/step1_submit.gif" onclick="return checkit();" /></form>
Well you could simply add runat="sever" to all your form fields (<input type="text" name="name" id="name" runat="server" />) on a .aspx page and then you'd be able access the values from those in code behind.
Personally I don't see any reason to use JQuery for this form other than to validate form field, which can be done with asp.net form validation controls anyway.
I agree with DarthSwian's opinion. If you want to validate a value, you can do it in the code behind. However, I am not sure the meaning about jquery sign up form to asp. Could you explain it more clearly?
Best wishes,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
They reason I'm using the jquery form is because it looks nice on my site. The problem is trying to understand what each for is saying, and I'm trying to understand each language so I can convert what one form is saying to the nice form, but in it's own
language.
It's like one form is saying: name= Si
Señor and the other is saying , name= yes sir. but I can figure out how to change all the fields to the right language. Sorry for blabing but I'm trying to explain.
They reason I'm using the jquery form is because it looks nice on my site. The problem is trying to understand what each for is saying, and I'm trying to understand each language so I can convert what one form is saying to the nice form, but in it's own
language.
It's like one form is saying: name= Si
Señor and the other is saying , name= yes sir. but I can figure out how to change all the fields to the right language. Sorry for blabing but I'm trying to explain.
Sorry, but that form is really just an html form. I don't see anything in your code that deals with language and that's really something that can be handled with localization so you present the user with text in their language if you support it. Whatever
you have going on on your processing page you didn't post, so we don't know what you're doing with the data once you get it.
Please show in your code sample where you're using jquery for anything. I see the link to script but only see a plain html form so maybe your sample is incomplete
// $(document).ready() is executed after the page DOM id loaded
// Binding an listener to the submit event on the form:
$('#signupForm').submit(function(e){
// If a previous submit is in progress:
if($('#submit').hasClass('active')) return false;
// Adding the active class to the button. Will show the preloader gif:
$('#submit').addClass('active');
// Removing the current error tooltips
$('.errorTip').remove();
// Issuing a POST ajax request to submit.php (the action attribute of the form):
$.post($('#signupForm').attr('action'),$('#signupForm').serialize()+'&fromAjax=1',function(response){
if(!response.status)
{
// Some kind of input error occured
// Looping through all the input text boxes,
// and checking whether they produced an error
$('input[type!=submit]').each(function(){
var elem = $(this);
var id = elem.attr('id');
// Helper function that creates an error tooltip:
function showTooltip(elem,txt)
{
// elem is the text box, txt is the error text
$('<div class="errorTip">').html(txt).appendTo(elem.closest('.formRow'));
}
// Checking the input data and adding potential errors to the $errors array:
if(!$_POST['name'] || strlen($_POST['name'])<3 || strlen($_POST['name'])>50)
{
$errors['name']='Please fill in a valid name!<br />Must be between 3 and 50 characters.';
}
if(!$_POST['email'] || !preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $_POST['email']))
{
$errors['email']='Please fill in a valid email!';
}
if(!$_POST['pass'] || strlen($_POST['pass'])<5)
{
$errors['pass']='Please fill in a valid password!<br />Must be at least 5 characters long.';
}
// Checking whether the request was sent via AJAX
// (we manually send the fromAjax var with the AJAX request):
if($_POST['fromAjax'])
{
if(count($errors))
{
$errString = array();
foreach($errors as $k=>$v)
{
// The name of the field that caused the error, and the
// error text are grouped as key/value pair for the JSON response:
$errString[]='"'.$k.'":"'.$v.'"';
}
// JSON error response:
die ('{"status":0,'.join(',',$errString).'}');
}
// JSON success response. Returns the redirect URL:
echo '{"status":1,"redirectURL":"'.$redirectURL.'"}';
exit;
}
// If the request was not sent via AJAX (probably JavaScript
// has been disabled in the visitors' browser):
ralph954
Member
9 Points
38 Posts
How to covert jquery sign up form to asp (or just transfer values)
May 03, 2012 10:10 PM|LINK
I have a jquery sign up form that I would like to convert to .asp values. I would like when a user click submit on the jquery form, for it to do the action of the .asp form. Thanks You.
THIS IS MY JQUERY:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Carbon Fiber Signup Form | Tutorialzine Demo</title>
<p><link rel="stylesheet" type="text/css" href="styles.css" /></p>
<div id="carbonForm">
<h1>Signup</h1>
<form action="submit.php" method="post" id="signupForm">
<div class="fieldContainer">
<div class="formRow">
<div class="label"><label for="name">Name:</label></div>
<div class="field"><input type="text" name="name" id="name" /></div>
</div>
<div class="formRow">
<div class="label"><label for="email">Email:</label></div>
<div class="field"><input type="text" name="email" id="email" /></div>
</div>
<div class="formRow">
<div class="label"><label for="pass">Password:</label></div>
<div class="field"><input type="password" name="pass" id="pass" /></div>
</div>
</div>
<!-- Closing fieldContainer -->
<div class="signupButton"><input type="submit" name="submit" id="submit" value="Signup" /></div>
</form></div>
<h2 id="footer"><a href="http://tutorialzine.com/2010/04/carbon-signup-form/">Go Back To The Tutorial »</a></h2>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>
THIS IS MY .ASP sign up SCRIPT:
<p><link href="../RTS/styles.css" rel="stylesheet" type="text/css" /></p>
<script language="javascript" type="text/javascript">// <![CDATA[
function checkit()
{
var stop=0
var msg=""
var valid = 1
var valid2 = 1
var no=0;
if(document.theform.folder.value=="" || document.theform.folder.value=="Folder Name"){stop=1;msg=msg+"\nYou need to input a folder name."}
if(document.theform.password.value==""){stop=1;msg=msg+"\nYou need to enter a password."}
if (document.theform.owneremail.value.indexOf("@") == -1){stop=1;msg=msg+"\nYou need to enter a valid E-mail Address."}
//if every thing looks good...submit it.
if (stop==1){alert(msg);msg="";return false;}
if (stop!=1&&no!=1){document.theform.submit();return true;}
}
// ]]></script>
<!--#include file="domain.txt"--><form action="qry_index1.asp" method="post" name="theform"><!----------------------------------start section 1-------------------------------------------------------><<%'dim arrtmp="Split(Request.ServerVariables("server_name"),"> <!--<font size="1" face="verdana" color="black"><strong>http://</strong></font><input type="text" name="folder" value="Folder Name" size="20" onFocus="javascript:document.theform.folder.value='';"><font size="1" face="verdana" color="black"><b>.<=arrTmp(1)%>.<=arrTmp(2)%>/</b></font>
--> <span size="1" face="verdana" color="black" style="color: black; font-family: verdana; font-size: xx-small;"><b><%=domain%>sites/<!--%=domain%--></b></span><input type="text" name="folder" value="Folder Name" size="20" onfocus="javascript:document.theform.folder.value='';" /> <!--%'dim-->
<div><span size="1" face="verdana" color="4B4B4B" style="color: #4b4b4b; font-family: verdana; font-size: xx-small;">Once your site is built you will be able to setup a custom domain (.com) name. </span></div>
<hr /><!------------------------------end-------------------------------------------------------><!------------------------------start section 2----------------------------------------------------------><<span size="1" face="verdana" color="black" style="color: black; font-family: verdana; font-size: xx-small;"><b>Your Password:</b></span><input type="password" name="password" /><span size="1" face="Verdana" color="4B4B4B" style="color: #4b4b4b; font-family: Verdana; font-size: xx-small;">* This password will allow you to get into your new web sites administration tool. That way you will be able to go back any time to quickly make changes to your site! </span><hr /><!------------------------------end-------------------------------------------------------><!------------------------------start section 3----------------------------------------------------------><<span size="1" face="verdana" color="black" style="color: black; font-family: verdana; font-size: xx-small;"><b>E-mail Address:</b></span><input name="owneremail" size="30" type="text" /><hr /><input type="image" src="images/step1_submit.gif" onclick="return checkit();" /></form>
DarthSwian
Star
12771 Points
2361 Posts
Re: How to covert jquery sign up form to asp (or just transfer values)
May 04, 2012 11:27 AM|LINK
Well you could simply add runat="sever" to all your form fields (<input type="text" name="name" id="name" runat="server" />) on a .aspx page and then you'd be able access the values from those in code behind.
Personally I don't see any reason to use JQuery for this form other than to validate form field, which can be done with asp.net form validation controls anyway.
Seek and ye shall find or http://lmgtfy.com/
Catherine Sh...
All-Star
23373 Points
2490 Posts
Microsoft
Re: How to covert jquery sign up form to asp (or just transfer values)
May 08, 2012 09:08 AM|LINK
Hi ralph954,
I agree with DarthSwian's opinion. If you want to validate a value, you can do it in the code behind. However, I am not sure the meaning about jquery sign up form to asp. Could you explain it more clearly?
Best wishes,
Feedback to us
Develop and promote your apps in Windows Store
ralph954
Member
9 Points
38 Posts
Re: How to covert jquery sign up form to asp (or just transfer values)
May 09, 2012 06:40 AM|LINK
They reason I'm using the jquery form is because it looks nice on my site. The problem is trying to understand what each for is saying, and I'm trying to understand each language so I can convert what one form is saying to the nice form, but in it's own language.
It's like one form is saying: name= Si Señor and the other is saying , name= yes sir. but I can figure out how to change all the fields to the right language. Sorry for blabing but I'm trying to explain.
ralph954
Member
9 Points
38 Posts
Re: How to covert jquery sign up form to asp (or just transfer values)
May 09, 2012 06:41 AM|LINK
They reason I'm using the jquery form is because it looks nice on my site. The problem is trying to understand what each for is saying, and I'm trying to understand each language so I can convert what one form is saying to the nice form, but in it's own language.
It's like one form is saying: name= Si Señor and the other is saying , name= yes sir. but I can figure out how to change all the fields to the right language. Sorry for blabing but I'm trying to explain.
DarthSwian
Star
12771 Points
2361 Posts
Re: How to covert jquery sign up form to asp (or just transfer values)
May 09, 2012 11:29 AM|LINK
Sorry, but that form is really just an html form. I don't see anything in your code that deals with language and that's really something that can be handled with localization so you present the user with text in their language if you support it. Whatever you have going on on your processing page you didn't post, so we don't know what you're doing with the data once you get it.
Seek and ye shall find or http://lmgtfy.com/
ralph954
Member
9 Points
38 Posts
Re: How to covert jquery sign up form to asp (or just transfer values)
May 09, 2012 04:53 PM|LINK
I was giving an analogy. I want this in english. By language I ment : Asp, jquery..etc.
DarthSwian
Star
12771 Points
2361 Posts
Re: How to covert jquery sign up form to asp (or just transfer values)
May 09, 2012 05:44 PM|LINK
Please show in your code sample where you're using jquery for anything. I see the link to script but only see a plain html form so maybe your sample is incomplete
Seek and ye shall find or http://lmgtfy.com/
ralph954
Member
9 Points
38 Posts
Re: How to covert jquery sign up form to asp (or just transfer values)
May 09, 2012 07:27 PM|LINK
DarthSwain you are a right. I downloaded the script from http://tutorialzine.com/2010/04/carbon-signup-form/ and thought it was jquery but it has a js.
HTML: (carbon form) this is the form I would like to intergrade with my site)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Carbon Fiber Signup Form | Tutorialzine Demo</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<div id="carbonForm">
<h1>Signup</h1>
<form action="submit.php" method="post" id="signupForm">
<div class="fieldContainer">
<div class="formRow">
<div class="label">
<label for="name">Name:</label>
</div>
<div class="field">
<input type="text" name="name" id="name" />
</div>
</div>
<div class="formRow">
<div class="label">
<label for="email">Email:</label>
</div>
<div class="field">
<input type="text" name="email" id="email" />
</div>
</div>
<div class="formRow">
<div class="label">
<label for="pass">Password:</label>
</div>
<div class="field">
<input type="password" name="pass" id="pass" />
</div>
</div>
</div> <!-- Closing fieldContainer -->
<div class="signupButton">
<input type="submit" name="submit" id="submit" value="Signup" />
</div>
</form>
</div>
<h2 id="footer"><a href="http://tutorialzine.com/2010/04/carbon-signup-form/">Go Back To The Tutorial »</a></h2>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
JS:
$(document).ready(function(){
// $(document).ready() is executed after the page DOM id loaded
// Binding an listener to the submit event on the form:
$('#signupForm').submit(function(e){
// If a previous submit is in progress:
if($('#submit').hasClass('active')) return false;
// Adding the active class to the button. Will show the preloader gif:
$('#submit').addClass('active');
// Removing the current error tooltips
$('.errorTip').remove();
// Issuing a POST ajax request to submit.php (the action attribute of the form):
$.post($('#signupForm').attr('action'),$('#signupForm').serialize()+'&fromAjax=1',function(response){
if(!response.status)
{
// Some kind of input error occured
// Looping through all the input text boxes,
// and checking whether they produced an error
$('input[type!=submit]').each(function(){
var elem = $(this);
var id = elem.attr('id');
if(response[id])
showTooltip(elem,response[id]);
});
}
else location.replace(response.redirectURL);
$('#submit').removeClass('active');
},'json');
e.preventDefault();
});
$(window).resize();
});
// Centering the form vertically on every window resize:
$(window).resize(function(){
var cf = $('#carbonForm');
$('#carbonForm').css('margin-top',($(window).height()-cf.outerHeight())/2)
});
// Helper function that creates an error tooltip:
function showTooltip(elem,txt)
{
// elem is the text box, txt is the error text
$('<div class="errorTip">').html(txt).appendTo(elem.closest('.formRow'));
}
PHP: (submit.php)
<?php
// Error reporting:
error_reporting(E_ALL^E_NOTICE);
// This is the URL your users are redirected,
// when registered succesfully:
$redirectURL = 'http://demo.tutorialzine.com/2010/04/carbon-signup-form/demo.html';
$errors = array();
// Checking the input data and adding potential errors to the $errors array:
if(!$_POST['name'] || strlen($_POST['name'])<3 || strlen($_POST['name'])>50)
{
$errors['name']='Please fill in a valid name!<br />Must be between 3 and 50 characters.';
}
if(!$_POST['email'] || !preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $_POST['email']))
{
$errors['email']='Please fill in a valid email!';
}
if(!$_POST['pass'] || strlen($_POST['pass'])<5)
{
$errors['pass']='Please fill in a valid password!<br />Must be at least 5 characters long.';
}
// Checking whether the request was sent via AJAX
// (we manually send the fromAjax var with the AJAX request):
if($_POST['fromAjax'])
{
if(count($errors))
{
$errString = array();
foreach($errors as $k=>$v)
{
// The name of the field that caused the error, and the
// error text are grouped as key/value pair for the JSON response:
$errString[]='"'.$k.'":"'.$v.'"';
}
// JSON error response:
die ('{"status":0,'.join(',',$errString).'}');
}
// JSON success response. Returns the redirect URL:
echo '{"status":1,"redirectURL":"'.$redirectURL.'"}';
exit;
}
// If the request was not sent via AJAX (probably JavaScript
// has been disabled in the visitors' browser):
if(count($errors))
{
echo '<h2>'.join('<br /><br />',$errors).'</h2>';
exit;
}
// Directly redirecting the visitor:
header("Location: ".$redirectURL);
?>