I have an old Html form already hooked up to Bronto already:
<div id="mc_embed_signup"><form id="lunar-form"><input name="fid" type="hidden" value="3yuzy87x8gjdf73zq9p6lav86dfdw" />
<input name="sid" type="hidden" value="01c3cd9e15ec122d6bada9aeba8dbe44" />
<input name="delid" type="hidden" value="" />
<input name="subid" type="hidden" value="" />
<input name="td" type="hidden" value="" />
<input name="formtype" type="hidden" value="addcontact" />
<input id="field_361909" class="hidden field" name="67765[361909]" type="hidden" value="Weekly" />
<input id="field_361796" class="hidden field" name="67746[361796]" type="hidden" value="Hair Shaman Lunar" />
<script type="text/javascript">
var fieldMaps = {};
</script>
<fieldset id="popupfieldset">
<div class="mc-field-group-email">
<input id="mce-EMAIL" class="text field fb-email" title="7 characters minimum" autocomplete="off" name="74662" pattern=".{7,}" required="" type="email" value="" placeholder="Email" />
i want to add another input for first name, how do I make sure it connects to the bronto database correctly?
Related
I have a html signup form in which I want to check whether password and re-entered password are same or not in Javascript.
Here is the code :
< script >
function pass() {
var pas = document.getElementById("pass");
var rpas = document.getElementById("rpass");
if (pas.value != rpas.value) {
document.getElementById("error").innerHTML = "Enter same password in Retype Password..";
} else {
document.getElementById("error").innerHTML = "";
}
}
<
/script>
<form action="">
<div id="signup" class="tab-content show">
<input type="text" placeholder="Name" name="name" id="name" />
<br />
<br />
<input type="password" placeholder="Password" name="pass" id="pass" />
<br />
<br />
<input type="password" placeholder="ReType Password" name="rpass" id="rpass" />
<br />
<br />
<input type="email" placeholder="Email" name="email" id="email" />
<br />
<br />
<input type="radio" value="Male" name="gender" id="gender" checked="checked" />Male
<input type="radio" value="FeMale" name="gender" id="gender" />Female
<br />
<br />
<input type="submit" value="Submit" name="submit" id="submit" onclick="pass()" />
<p id="error"></p>
</div>
</form>
Problem is that Javascript is not working..
The problem is that you are submitting the form there. You have used onClick event on submit button, but when submit button is pressed form is submitted and you can call a function in the form tag in onSubmit attribute and then you have to stop form submission otherwise the form will be submitted and the page will reload
You need to change input type "submit" to input type="button".
<script >
function pass(){
var pas = document.getElementById("pass");
var rpas = document.getElementById("rpass");
if (pas.value != rpas.value){
document.getElementById("error").innerHTML="Enter same password in Retype Password..";
}
else{
document.getElementById("error").innerHTML="";
}
}
</script>
<form action="">
<div id="signup" class="tab-content show">
<input type="text" placeholder="Name" name="name" id="name" />
<br />
<br />
<input type="password" placeholder="Password" name="pass" id="pass" />
<br />
<br />
<input type="password" placeholder="ReType Password" name="rpass" id="rpass" />
<br />
<br />
<input type="email" placeholder="Email" name="email" id="email" />
<br />
<br />
<input type="radio" value="Male" name="gender" id="gender" checked="checked"/>Male
<input type="radio" value="FeMale" name="gender" id="gender" />Female
<br />
<br />
<input type="button" value="Submit" name="submit" id="submit" onclick="pass()" />
<p id="error"></p>
</div>
</form>
You can check below code on W3schools
<!DOCTYPE html>
<html>
<body>
<h2>HTML Forms</h2>
<form action="">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
Password:<br>
<input type="password" name="password" id="pswd">
<br><br>
Re-Password:<br>
<input type="password" name="password" id="rpswd">
<br><br>
<input type="button" value="Submit" onclick="pass()">
</form>
<p>If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php".</p>
<script>
function pass() {
var paswd = document.getElementById("pswd").value;
var rpswd = document.getElementById("rpswd").value;
alert(paswd !== rpswd);
}
</script>
</body>
</html>
Also you can follow the answer of whis san
I have a form with variable number of inputs as an array
<form>
<label for="same">all the same as first?</label>
<input type="text" id="foo[1]" name="foo[1]" value="" />
<input type="text" id="foo[2]" name="foo[2]" value="" />
<input type="text" id="foo[3]" name="foo[3]" value="" />
<input type="text" id="foo[4]" name="foo[4]" value="" />
<input type="text" id="foo[5]" name="foo[5]" value="" />
</form>
The idea is when i put some value in the first field (foo[1]) i need the jQuery or Javascript copy the value from #foo[1] into #foo[2], #foo[3], etc depending on the array.
Do you need following behavior :
$(document).ready(function(){
$("input[id^=foo\\[]").prop("disabled",true); //disable all elements first
$("input#foo\\[1\\]").prop("disabled",false); //then enable the first one
$("input#foo\\[1\\]").change(function(){
var source = $(this);
var currentVal = $(source).val();
$("input[id^=foo\\[]").each(function(){
if(!$(this).is(source))
$(this).val(currentVal);
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<form>
<label for="same">all the same as first?</label>
<input type="text" id="foo[1]" name="foo[1]" value="" />
<input type="text" id="foo[2]" name="foo[2]" value=""/>
<input type="text" id="foo[3]" name="foo[3]" value=""/>
<input type="text" id="foo[4]" name="foo[4]" value=""/>
<input type="text" id="foo[5]" name="foo[5]" value=""/>
</form>
$('input').on('input', function(){
$(this).siblings().val($(this).val());
});
Couldn't tell if you just wanted the first or all. If just the first, you can target with an id or jQuery.
$('input').eq(0).on('input', function(){});
Something like this
HTML
<form>
<label for="same">all the same as first?</label>
<input type="text" id="foo[1]" name="foo[1]" value="" />
<input type="text" id="foo[2]" name="foo[2]" value="" />
<input type="text" id="foo[3]" name="foo[3]" value="" />
<input type="text" id="foo[4]" name="foo[4]" value="" />
<input type="text" id="foo[5]" name="foo[5]" value="" />
</form>
JavaScript
$("input[id=foo\\[1\\]").on("input", function (){
$(this).siblings().val($(this).val());
});
And if you want the other to be readonly:
$("input[id^=foo\\[]:not([id=foo\\[1\\]])").attr("readonly", "readonly");
I have this form
<form name="myForm" action="" method="post" onsubmit="return validations(this)" >
<span>
<label>Enter Your First Name</label><input id="name" name= "field[1]" type="text" class="element text" maxlength="255" size="8" value=""/>
</span>
<br /><br />
<span>
<label>Enter Your Last Name</label><input id="last" name= "field[2]" type="text" class="element text" maxlength="255" size="8" value=""/>
</span>
<br />
<br />
<span>
<input id="field[3]" name="field[3]" class="element radio" type="radio" value="1" />
<.label class="choice" for="field[3]">Male</label>
<input id="field[4]" name="field[4]" class="element radio" type="radio" value="2" />
<label class="choice" for="field[4]">Female</label>
</span>
<br /><br />
<label class="description" for="field[5]">Enter your city </label><input id="field[5]" name="element_3" type="text" class="element text medium" type="text" maxlength="255" value=""/>
<br /><br />
<span>
<input id="field[5]" name="field[5]" class="element checkbox" type="checkbox" value="1" />
<.label class="choice" for="field[5]">I am unemployed.</label>
<br /><br />
</span>
<input type="hidden" name="form_id" value="form1" />
</div>
.
<.input type="submit" value="Validate" >
</form>
and i want to validate the form on click "Validate". to check if all fields type=text are completed.How can i do this dynamically?
You can do it using
Plain JavaScript checks, write a function and validate each field on clicking of submit button
jQuery validation plugin if you are using jQuery. Include the jQuery and jQuery validation plugin in your html page, add class="required" to your text fields and finally add a JavaScript code to attach validation.
The second is simple as it only need to call validate function and set class="required" for your text fields
ex:
Including jQuery and validation plugin in your html head tag
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js" type="text/javascript"></script>
to attach validation to your form, add this code in head section or anywhere in body
<script type="text/javascript">
jQuery(document).ready(function($){
$('form[name="myForm"]').validate();
});
</script>
Now your form fields:
<form name="myForm" action="" method="post">
<input type="text" class="required" name="..." ...>
or simply
<input type="text" name="..." required>
.... all other fields
</form>
so i have a list of addresses each with edit links and i want to grab the ID of the input within the list item
<li class="last">
<div class="checkout-select-address"><input type="radio" name="checkout_selected_address" id="checkout_selected_address_3" value="" /></div>
<div class="checkout-select-address-details">
<p><label for="checkout_selected_address_3">(Mothers)</label> Edit Address</p>
<input type="hidden" id="checkout_selected_address_3_name" value="" />
<input type="hidden" id="checkout_selected_address_3_title" value="" />
<input type="hidden" id="checkout_selected_address_3_first_name" value="" />
<input type="hidden" id="checkout_selected_address_3_last_name" value="" />
<input type="hidden" id="checkout_selected_address_3_address_line_1" value="" />
<input type="hidden" id="checkout_selected_address_3_address_line_2" value="" />
<input type="hidden" id="checkout_selected_address_3_address_line_3" value="" />
<input type="hidden" id="checkout_selected_address_3_town_city" value="" />
<input type="hidden" id="checkout_selected_address_3_county" value="" />
<input type="hidden" id="checkout_selected_address_3_postcode" value="" />
<input type="hidden" id="checkout_selected_address_3_country" value="" />
</div>
<div class="clear"></div>
so clicking on the link with class "edit-link" it will get the ID for the radio input within the li
Thanks in advance
try this :
$(".edit-link").click(function(){
alert($(this).closest("li").find("input[type=radio]").attr("id"));
});
demo : http://jsfiddle.net/ZABBS/
I have this form for a dedicated iphone landing page. but cant find anything that will deal with the validation. i only need to validate the number but the name could also be usefull. i cant seem to find anything that will alert the user the field has not been entered.
this is iphone only and is a web form not a app
<form method="post" action="submitquote.php" name="quoteform">
<label>Your Full Name</label>
<input style="outline:none;" id="name" type="text" name="name" size="20" value="" class="elements"/>
<label>Your Email Address</label>
<input style="outline:none;" id="email" type="email" name="email" size="20" value="" class="elements"/>
<label>Your Telephone Number</label>
<input style="outline:none;" id="telephone" type="text" pattern="[0-9]*" name="telephone" size="20" value="" class="elements">
<label>Company Postcode</label>
<input style="outline:none;" id="postcode" type="text" name="postcode" size="20" value="" class="input" />
<div class="saveon">Save on..</div>
<div class="checkboxs">Gas<input type="hidden" name="gasresult" value="no" /><input name="gasresult" type="checkbox" value="yes" checked="checked" /> Electricity<input type="hidden" name="electricresult" value="no" /><input name="electricresult" type="checkbox" value="yes" checked="checked" /></div>
<input type="hidden" value="<?php echo $myid ?>" name="track" />
<input type="hidden" value="<?php echo $_GET['utm_source']; ?>" name="utm_source" />
<input type="hidden" value="<?php echo $_GET['utm_medium']; ?>" name="utm_medium" />
<input type="hidden" value="<?php echo $_GET['utm_term']; ?>" name="utm_term" />
<input type="hidden" value="<?php echo $_GET['utm_content']; ?>" name="utm_content" />
<input type="hidden" value="<?php echo $_GET['utm_campaign']; ?>" name="utm_campaign" />
<input type="submit" value="" class="submit" onclick="pageTracker._trackPageview('/HomePage/ClassicQuoteRequest/Submit')" />
</form>
You can use JavaScript to get the value of an input object of a form.
function nameOK() {
var myForm = document.quoteform; // document.#nameOfForm#
var input = myForm.name;
var content = input.value;
return (content != "");
}
It is untested, but I have recently done something similar to store cookies.
Hope it works,
ief2