Edit localStorage user? - javascript

Hello i am trying to edit the user with localStorage, but can't seem to parse the value of my user info to the input field of my "EditUser" form.
I have read that set/getItem() should be used, but have tried with my User:index without success.
How can i EDIT the current user that has logged in via localStorage?
Fiddle example
http://jsfiddle.net/f3dsfpob/6/
HTML
<form id="userReg">
<div class="item text">
<label>Username:</label>
<div class="field">
<input type="text" name="user_name" id="nameUSER" />
</div>
</div>
<div class="item text">
<label>Password:</label>
<div class="field">
<input type="password" name="password" />
</div>
</div>
<div class="button-wrapper">
<div class="item button button-default">
<div class="field">
<input type="submit" id="registerUser" value="Register" />
</div>
</div>
</div>
<input type="hidden" name="id_entry" value="0" />
</form>
<fieldset name="Login" id="logUser">
<legend>Login</legend>
<input type="text" name="first_name" id="firstName" />
<br />
<input type="password" id="passWord" />
<br />
<div class="item button">
<div class="field">
<input type="button" id="logIN" value="login" />
</div>
</div>
<p id="result"></p>
<p id="negative"></p>
</fieldset>
<div id="form">
<form id="EditUser">
<table class="form">
<tr>
<td>
<input type="text" name="changeUser" placeholder="username" />
</td>
</tr>
<tr>
<td>
<input type="text" name="changePass" placeholder="password" />
</td>
</tr>
<tr>
<td colspan="2" class="button">
<input id="formSubmit" type="button" value="Undo" onClick="dbClear()" />
<input id="formSubmit" type="button" value="Change" onClick="dbEdit()" />
</td>
</tr>
</table>
<input id="inputAction" type="hidden" name="action" value="add" />
<input id="inputKey" type="hidden" name="key" value="0" />
</form>
</div>
<p id="loginResult"></p>
<p id="negative"></p>
<p id="registerResult"></p>
JAVASCRIPT
var User = {
index: window.localStorage.getItem("User:index"),
$form: document.getElementById("userReg"),
$button_register: document.getElementById("registerUser"),
$button_login: document.getElementById("logIN"),
init: function () {
if (!User.index) {
window.localStorage.setItem("User:index", User.index = 1);
}
User.$form.addEventListener("submit", function (e) {
var entry = {
id: parseInt(this.id_entry.value),
user_name: this.user_name.value,
password: this.password.value,
e_mail: this.e_mail.value
};
if (entry.id == 0) {
User.storeAdd(entry);
}
e.preventDefault();
}, true);
User.$button_login.addEventListener("click", function (e) {
for(var i = 1; i < User.index; i++) {
var key = "User:" + i;
var entry = JSON.parse(localStorage[key]);
console.log("entry : ", key, entry);
if (document.getElementById("firstName").value == entry.user_name && document.getElementById("passWord").value == entry.password) {
alert("Logged in as"+" "+entry.user_name);
document.getElementById("loginResult").innerHTML = "Logged in as"+" "+entry.user_name;
console.log("entry : ", key, entry);
LoginUser();
e.preventDefault(e);
}
else
{
document.getElementById("negative").innerHTML = "Username or Password does not match";
}
}
});
},
storeAdd: function (entry) {
entry.id = User.index;
window.localStorage.setItem("User:index", ++User.index);
window.localStorage.setItem("User:" + entry.id, JSON.stringify(entry));
document.getElementById("registerResult").innerHTML = "Registration succesful";
return;
}
};
User.init();

You have a couple of things wrong.
e_mail: this.e_mail.value
There is no email field. This throws an error and makes your form submit handler not prevent default.
Btw - it may not be a good idea to store user info in LocalStorage like that.

Related

Show all values returned from an AJAX request

I have a query to select the data from my database:
function check_po_kode()
{
$key = $this->input->post('key');
$this->db->select('a.NO, b.quantity, b.satuan, b.harga, b.discount, b.sparepart_kode, b.sparepart_name, c.id as id_sparepart');
$this->db->from('purchase_order a');
$this->db->join('purchase_order_item b', 'a.id = b.purchase_order_id');
$this->db->join('sparepart c', 'c.kode = b.sparepart_kode');
$this->db->where(array('a.NO'=>$key));
$result = $this->db->get()->row_array();
if (count($result) > 0)
{
echo json_encode(array('status'=> 1, 'qty_po'=> $result['quantity'], 'satuan'=> $result['satuan'], 'harga'=> $result['harga'], 'discount'=> $result['discount'], 'sparepart_name'=> $result['sparepart_name'], 'sparepart_kode'=> $result['sparepart_kode'], 'id_sparepart'=> $result['id_sparepart'], 'jmlhSparepart'=> $result['jmlhSparepart']));
}
else
{
echo json_encode(array('status'=> 0));
}
}
I already have the result. I want to then show the data in the page with this AJAX code:
//check purchase order kode
$("#purchase-order-kode").blur(function() {
var key = $(this).val();
$.ajax({
url: '<?php echo base_url('
purchase_order / check_po_kode '); ?>',
type: 'post',
dataType: 'json',
data: {
key: key
},
error: function() { },
success: function(res) {
console.log(res);
if (res.status == 1) {
$("#purchase-order-kode-notif").html("Valid");
$('#form').find('#sparepart_id').val(res.id_sparepart);
$('#form').find('#sparepart_kode').val(res.sparepart_kode);
$('#form').find('#sparepart_name').val(res.sparepart_name);
$('#form').find('#quantity').val(res.qty_po);
$('#form').find('#unit').val(res.satuan);
$('#form').find('#price').val(res.harga);
$('#form').find('#discount').val(res.discount);
$('#button_post').prop('disabled', false);
} else {
$("#purchase-order-kode-notif").html("Invalid Kode!");
$('#button_post').prop('disabled', true);
}
}
});
});
<div class="transport-row form-box" style="display: inline-block; width: 1250px">
<h4>Input Item</h4>
<div style="margin-bottom: 20px"></div>
<div class="row-fluid sparepart-row">
<div class="control-group">
<div class="span4">
<fieldset>
<label>Nama Barang</label>
<input type="hidden" name="sparepart_id[]" id="sparepart_id">
<input type="text" name="sparepart_kode[]" class="stok_barang_id" id="sparepart_kode" placeholder=" Kode" readonly style="width: 100px; padding-bottom:4px;">
<div class="input-append">
<input type="text" name="sparepart_name[]" class="stok_barang_name" id="sparepart_name" readonly placeholder="Sparepart name" title="" style="padding-bottom:4px;">
<span class="add-on">
<i data-title="" ime-icon="icon-time" data-date-icon="icon-search" class="icon-search"></i>
</span>
</div>
</fieldset>
</div>
<div class="span1 span-qty">
<fieldset>
<label>Quantity</label>
<input type="text" name="quantity[]" id="quantity" class="quantity" placeholder="99" style="width:65px;" />
</fieldset>
</div>
<div class="span1 span-qty">
<fieldset>
<label>Unit</label>
<input type="text" id="unit" class="unit" placeholder="Unit" style="width: 65px;" readonly/>
</fieldset>
</div>
<div class="span2 span-harga">
<fieldset>
<label>Price</label>
<input type="text" name="price[]" id="price" class="price" value="" placeholder="999" style="width:160px;" readonly/>
</fieldset>
</div>
<div class="span3 span-harga">
<fieldset>
<label>Discount</label>
<input type="text" name="discount[]" id="discount" class="discount" value="" placeholder="10%" style="width:160px;">
<button class="btn btn-primary" id="add_row">+</button>
</fieldset>
</div>
</div>
</div>
</div>
With the above code I succeed in showing only 1 item in the data. If I run that query with Number PO, there is 2 or 3 items returned. How can I show all data from the AJAX request above?
EDIT :
I already tried with :
//check purchase order kode
$("#purchase-order-kode").blur(function(){
var key = $(this).val();
$.ajax({
url : '<?php echo base_url('purchase_order/check_po_kode'); ?>',
type : 'post',
dataType : 'json',
data : {key:key},
error : function(){
},
success : function(res){
console.log(res);
if(res.status == 1){
$("#purchase-order-kode-notif").html("Valid"); $.each(res,function(index,item){ $('#form').find('#sparepart_id').text(item.id_sparepart), $('#form').find('#sparepart_kode').text(item.sparepart_kode), $('#form').find('#sparepart_name').text(item.sparepart_name), $('#form').find('#quantity').text(item.qty_po), $('#form').find('#unit').text(item.satuan), $('#form').find('#price').text(item.harga), $('#form').find('#discount').text(item.discount);
});
$('#button_post').prop('disabled', false);
}else{
$("#purchase-order-kode-notif").html("Invalid Kode!");
$('#button_post').prop('disabled', true);
}
}
});
});
with above code, i cannot showing any data.
i think something like this could be help:
Object.keys(res).forEach(function(item) {
let field = $('#form').find('#' + item);
if (field) field .val(res[item])
})
if your 'res' is just values of fields, then with this code you can dynamically fill all fields.
here is snippet sample:
const res = {
status: 1,
quantity: "1",
unit: "pcs",
price: "59000000",
discount: "0",
sparepart_name: "SHOCK",
sparepart_kode: "MDBUS",
sparepart_id: "2120"
};
$(function() {
$(document).ready(function() {
Object.keys(res).forEach(function(item) {
let field = $('#' + item);
if (field) field.val(res[item])
})
});
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="transport-row form-box" style="display: inline-block; width: 1250px">
<h4>Input Item</h4>
<div style="margin-bottom: 20px"></div>
<div class="row-fluid sparepart-row">
<div class="control-group">
<div class="span4">
<fieldset>
<label>Nama Barang</label>
<input type="hidden" name="sparepart_id[]" id="sparepart_id">
<input type="text" name="sparepart_kode[]" class="stok_barang_id" id="sparepart_kode" placeholder=" Kode" readonly style="width: 100px; padding-bottom:4px;">
<div class="input-append">
<input type="text" name="sparepart_name[]" class="stok_barang_name" id="sparepart_name" readonly placeholder="Sparepart name" title="" style="padding-bottom:4px;">
<span class="add-on">
<i data-title="" ime-icon="icon-time" data-date-icon="icon-search" class="icon-search"></i>
</span>
</div>
</fieldset>
</div>
<div class="span1 span-qty">
<fieldset>
<label>Quantity</label>
<input type="text" name="quantity[]" id="quantity" class="quantity" placeholder="99" style="width:65px;" />
</fieldset>
</div>
<div class="span1 span-qty">
<fieldset>
<label>Unit</label>
<input type="text" id="unit" class="unit" placeholder="Unit" style="width: 65px;" readonly/>
</fieldset>
</div>
<div class="span2 span-harga">
<fieldset>
<label>Price</label>
<input type="text" name="price[]" id="price" class="price" value="" placeholder="999" style="width:160px;" readonly/>
</fieldset>
</div>
<div class="span3 span-harga">
<fieldset>
<label>Discount</label>
<input type="text" name="discount[]" id="discount" class="discount" value="" placeholder="10%" style="width:160px;">
<button class="btn btn-primary" id="add_row">+</button>
</fieldset>
</div>
</div>
</div>
</div>

How to get values from input boxes and save to database with button click angular

I'm still learning to programme on AngularJS.
I want to get values from the input box and then click on the button I want to save them in the database.
My database table is called "user". I have columns like id, username, password, name.
I have two checkbox.When I click on first checkbox(Edit) it displaying "div myVar",when i click on second checkbox(Add new user) it displaying "div myVar1".
I want to activate this button "Add" to add input box values to database MySQL. Please help me.
I have this html code:
<label><input type="checkbox" ng-model="myVar">Edit</label>
<label><input type="checkbox" ng-model="myVar1">Add new user</label>
<div ng-show="myVar">
<div class="form">
<form ng-submit="saveItem(userForm.$valid)" name="userForm">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="database_address">User</label>
<input type="text" class="form-control" required ng-model="activeItem.username" placeholder="Потребителско Име..." />
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="text" class="form-control" required id="password" ng-model="activeItem.password" />
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="username">Operator</label>
<input type="text" class="form-control" required id="username" ng-model="activeItem.name" />
</div>
</div>
</div>
<button class="btn btn-primary" ng-disabled="userForm.$invalid" type="submit">Save</button>
<!--<button class="btn btn-primary" ng-disabled="userForm.$invalid" type="submit">Добавяне на нов</button>-->
</form><form ng-submit="createUser(userForm.$valid)" name="userForm1">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="database_address">User</label>
<input type="text" class="form-control1" ng-model="usernamee" placeholder="Потребителско Име..." />
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="text" class="form-control1" ng-model="passwordd"required id="password" />
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="username">Operator</label>
<input type="text" class="form-control1" ng-model="namee" required id="username" />
</div>
</div>
</div>
<button class="btn btn-primary" ng-click="createUser();" type="submit">Add user</button>
<!--<button class="btn btn-primary" ng-disabled="userForm.$invalid" type="submit">Добавяне на нов</button>-->
</form>
And Angular code:
$scope.createUser=function()
{
//console.log($scope.activeItem);
//delete $scope.activeItem.hash_method
var objectToSave = {
username: $scope.usernamee,
password: $scope.passwordd,
name: $scope.namee,
id: $scope.id
};
{
defaultAdapter.query('INSERT INTO users(username,password,name,id) VALUES(username = :usernamee, password = :passwordd,name = :namee WHERE id =:id)',
{ replacements: objectToSave, type: Sequelize.QueryTypes.UPDATE }
).then(projects => {
console.log(projects);
$scope.editMode = false;
$scope.activeItem = false;
$scope.refresh();
});
}
}

My script returns the first item only

I'm coding with asp.net/ c# and i'm trying to get the id and the quantity of a product using ajax. The problem is that my code only recognize the first item otherwise if i tried to enter the quantity of the third product i get an error saying that I haven't provided any quantity.
here's my code :
<script type="text/javascript">
$(function() {
$('.Sendparams').click(function (e) {
e.preventDefault();
debugger;
// var id = $(this).attr('id');
var quant = $("#quant").val();
var id = $("#id").val();
$.ajax({
type: 'GET',
url: '/ShoppingCart/AddToCart',
data:{ "id": id , "quant": quant },
success: function (response) {
$("#mainContainerCenter").html(response); } });});
});
</script>
<section class="content">
<!-- Small boxes (Stat box) -->
<div class="row">
#foreach (var album in Model.Produits)
{
<div class="col-lg-3 col-xs-6">
#Html.Hidden("id", album.ProduitId, new { #id = "id" })<br/>
#album.Nom_Produit<br />
#album.Categorie.Nom_categorie<br />
#String.Format("{0:F}", album.Prix)<br />
#Html.TextBox("quant", null, new { id = "quant" })<br />
#Html.ActionLink("voila", "AddToCart", "ShoppingCart", new { id = album.ProduitId }, new { #class = "Sendparams" })<br />
</div>
}
</div>
id attribute would be the uniq value. In your case the id is not the uniq, you using the "quant" value for all items (id="quant"). If i correctly understand what you try to do this is code can help: https://jsfiddle.net/9usvg6wv/
$(".item").submit(function( event ) {
$('#clickedid').text(
$(this).find('input[name="id"]').val()
);
$('#clickedquant').text(
$(this).find('input[name="quant"]').val()
);
console.log($(this).find('input[name="quant"]').val());
event.preventDefault();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<form action="" class="item" >
<input type="hidden" name="id" value="1" />
<input type="text" name="quant" value="100" />
<input type="submit" class="" >
</form>
<form action="" class="item" >
<input type="hidden" name="id" value="2" />
<input type="text" name="quant" value="200" />
<input type="submit" class="" >
</form>
<form action="" class="item" >
<input type="hidden" name="id" value="3" />
<input type="text" name="quant" value="300" />
<input type="submit" class="" >
</form>
<form action="" class="item" >
<input type="hidden" name="id" value="4" />
<input type="text" name="quant" value="400" />
<input type="submit" class="" >
</form>
</div>
<div>
Clicked id:<span id="clickedid"></span>; quant:<span id="clickedquant"></span>
</div>

javascript function to insert values from content-editable span to a hidden form

I am trying to fetch values from editable spans for hidden form to a hidden form via this javascript:
<script type="text/javascript">
function fillup() {
document.getElementById('fname').value = document.getElementById('nfname').innerHTML;
document.getElementById('mname').value = document.getElementById('nmname').innerHTML;
document.getElementById('lname').value = document.getElementById('nlname').innerHTML;
document.getElementById('email').value = document.getElementById('nemail').innerHTML;
document.getElementById('gen').value = document.getElementById('ngen').innerHTML;
document.getElementById('dob').value = document.getElementById('ndob').innerHTML;
var str = document.getElementById('nloc').innerHTML;
var parts = str.split(',');
document.getElementById('city').value = parts[0];
document.getElementById('state').value = parts[1];
if(document.getElementById('fname').value == '' || document.getElementById('mname').value == '' || document.getElementById('lname').value == '' || document.getElementById('email').value == '' || document.getElementById('gen').value == '' || document.getElementById('dob').value == '' || document.getElementById('city').value == '' || document.getElementById('state') == '' ){
alert('something is empty!');
}
else {
alert(str);
}
}
</script>
and following is the form:
<form method="post" action="{{ path('admin_update') }}">
<div class="hidden">
<input type="text" id="fname" name="fname" />
<input type="text" id="mname" name="mname" />
<input type="text" id="lname" name="lname" />
<input type="email" id="mail" name="email" />
<input type="text" id="gen" name="gen" />
<input type="text" id="dob" name="dob" />
<input type="text" id="city" name="city" />
<input type="text" id="state" name="state" />
</div>
<input type="submit" id="btn" value="save changes" onclick="fillup()" />
</form>
as said earlier, except the submit button other textareas are disabled in the form, the spans are:
<div class="row">
<div class="fname">
<span class="fname" id="nfname" contenteditable="true" onchange="appear()">{{ fname }}</span>
<hr />
<span class="st">First name</span>
</div>
<div class="mname">
<span class="mname" id="nmname" contenteditable="true" onchange="appear()">{{ mname }}</span>
<hr />
<span class="st">Middle name</span>
</div>
<div class="lname">
<span class="lname" id="nlname" contenteditable="true" onchange="appear()">{{ lname }}</span>
<hr />
<span class="st">Last name</span>
</div>
</div>
<div class="row">
<div class="email">
<span class="email" id="nemail" contenteditable="true">{{ email }}</span>
<hr />
<span class="st">Email</span>
</div>
</div>
<div class="row">
<div class="gender">
<span class="gender" id="ngen" contenteditable="true">{{ gen }}</span>
<hr />
<span class="st">Gender</span>
</div>
<div class="DOB">
<span class="DOB" id="ndob" contenteditable="true" id="datepicker">{{ dob|date("m/d/Y") }}</span>
<hr />
<span class="st">Date of birth</span>
</div>
<div class="loc">
<span class="loc" id="nloc" contenteditable="false">{{ loc }}</span>
<hr />
<span class="st">Location</span>
</div>
I've put your code into a plunkr
https://plnkr.co/edit/n8m58L7dFiFOPJBKJfvI?p=preview
To me it looks ok - and it definitly works, as far as I understand your requirement.
I would suggest to bind the function call "fillup()" to the onSubmit event of the form.
<form method="post" action="." onSubmit="fillup()">
Also please check for this line in the function:
document.getElementById('email').value = document.getElementById('nemail').innerHTML;
The element's id is NOT "email" - it is "mail"

Must Check box to submit form

Trying to create a form that will force people to select the checkbox with the phrase "I accept the terms and conditions" in order to send the form.
This is what I have but it is not submitting the form — I get an error.
Javascript that I have placed in the header:
<script type="text/javascript">
<!--
function validate_form ( )
{
valid = true;
if ( document.form1.cb.checked == false )
{
alert ( "Please check the Terms & Conditions box ." );
valid = false;
}
return valid;
}
//-->
</script>
Form:
<form action="/cgi-bin/FormMail.pl" method="POST" name="frmOne" id="frmOne">
<input type=hidden name="recipient" value="XXX#XXX.com"/>
<table width="100%" cellspacing="5" cellpadding="5" style="margin-top:-20px">
<tr>
<td width="50%" valign="top">
<br/>
<p><span id="sprytextfield1">
<label for="Full Name">Full Name (First and Last): </label>
<input name="Full Name" type="text" id="name" tabindex="10" size="60" />
<span class="textfieldRequiredMsg"><br />Please provide information.</span></span> </p>
<p><span id="sprytextfield2">
<label for="Your Email">Your e-mail address: </label>
<input name="email" type="text" id="email" size="60" />
<span class="textfieldInvalidFormatMsg"></span></span> </p>
<p><span id="sprytextfield3">
<label for="Phone Number"> Phone Number: </label>
<input name="Phone Number" type="text" id="phone" size="60" />
<span class="textfieldInvalidFormatMsg"><br />Invalid format.</span><span class="textfieldRequiredMsg"><br/>A phone number is required.</span></span></p>
<p class="text">
<span id="sprytextfield4">
<label for="Nature Of The Accident">Nature of Accident, i.e. slip and fall, motor vehicle accident, etc.: </label>
<input name="Nature Of The Accident" type="text" id="natureOfAccident" size="60" />
</span></p>
<p><span id="sprytextfield5">
<label for="Date Of The Accident">Date of the Accident: </label>
<input name="Date Of The Accident" type="text" id="dateOfAccident" size="60" />
<span class="textfieldRequiredMsg"><br />Please provide information.</span><span class="textfieldInvalidFormatMsg"><br />Invalid format.</span></span></p>
<p class="text">
</td>
<td width="50%" valign="top">
<p class="text">
<span id="sprytextarea1">
<label for="Description Of The Injury"><br />Brief Description of your Injuries: </label>
<textarea name="Description Of The Injury" cols="45" rows="4" id="descriptionOfInjury">
</textarea>
<span class="textareaRequiredMsg"><br />Please provide information.</span></span></p>
<p class="text">
<span id="sprytextarea2">
<label for="Description Of The Accident">Brief Description of the Accident:</label>
<textarea name="Description Of The Accident" id="descriptionOfAccident" cols="45" rows="4"></textarea>
<span class="textareaRequiredMsg"><br />
Please provide information.</span></span></p>
<p class="text">
<span id="sprytextfield6">
<label for="How Did You Hear About Us">How did you hear about us?: </label>
<input name="How Did You Hear About Us" type="text" id="howDidYouHear" size="56" />
<span class="textfieldRequiredMsg"><br />Please provide information.</span></span> </p>
<input type="checkbox" name="agree" value="agree_terms" id="disclaimer" />
<label for="disclaimer">I have read the Disclaimer</label>
<br/><br />
<input type="reset" name="reset" id="reset" value="Reset Form" />
<input type="submit" name="Form Action" id="send" tabindex="100" value="Submit" />
</td>
</tr>
</table>
</form>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur", "change"]});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email", {validateOn:["blur", "change"], isRequired:false});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "phone_number", {validateOn:["blur"], useCharacterMasking:true});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "none", {isRequired:false, validateOn:["blur", "change"]});
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "date", {hint:"dd/mm/yyyy", validateOn:["blur", "change"], format:"dd/mm/yyyy"});
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {validateOn:["blur", "change"]});
var sprytextarea2 = new Spry.Widget.ValidationTextarea("sprytextarea2", {validateOn:["blur", "change"]});
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "none", {validateOn:["blur", "change"], hint:"Google, etc"});
//-->
</script></div>
You are referencing the form and elements wrong, try something like this:
<form name="frmOne" method="POST" onSubmit="return checkForm(frmOne);" action="/cgi-bin/FormMail.pl">
<script>
function checkForm(form)
{
if(!form.agree.checked)
{
alert("You must agree to this disclaimer before applying.");
return false;
}
}
</script>
I hope that helped
Change <form action="/cgi-bin/FormMail.pl" method="POST" name="frmOne" id="frmOne"> to <form action="/cgi-bin/FormMail.pl" method="POST" name="frmOne" id="frmOne" onSubmit="validate_form();">
What other errors are you getting?
and change document.form1.cb.checked to document.frmOne.agree.checked
Give a try with document.getElementById("disclaimer").checked == false.

Categories

Resources