condition field password (Password Protection) - forms

I created a webform (Registration) Via phpform.org but I want make a condition for a field (Password) Like that (if password field is equal to 'test' then show Submit field )
<li id="li_2" >
<label class="description" for="element_2">Name </label>
<span>
<input id="element_2_1" name= "element_2_1" class="element text" maxlength="255" size="8" value=""/>
<label>First</label>
</span>
<span>
<input id="element_2_2" name= "element_2_2" class="element text" maxlength="255" size="14" value=""/>
<label>Last</label>
</span>
</li> <li id="li_1" >
<label class="description" for="element_1">Password </label>
<div>
<input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li>
<li class="buttons">
<input type="hidden" name="form_id" value="677911" />
<input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
</li>
</ul>
</form>
<div id="footer">
Generated by pForm
</div>
</div>
<img id="bottom" src="bottom.png" alt="">
</body>
Please how can I do that ?

You may use jQuery:
$(".buttons").hide();
$("#element_1").keyup(function () {
if ($(this).val() == "test") {
$(".buttons").show();
} else {
$(".buttons").hide();
}
});
See it working here: http://jsfiddle.net/7UtHW/.

Related

Angular Form Validation error : form is undefined

I am trying to validate my data for a student object with Angular Form Validation, but when I want to use or print for example, the serialNumber of a student it gives me this error: Cannot read property 'serialNumber' of undefined.
Here is the code:
<div *ngIf="student">
<div class=container>
<h2>Student {{student.name}} details</h2>
<form name="studentForm" (ngSubmit)="save()">
<!--<div ng-class="{ 'has-error' : studentForm.serialNumber.$invalid && !studentForm.serialNumber.t">-->
<label>Serial number: {{student.serialNumber}} </label>
<input type="text" name="serialNumber" class="form-control" ng-model="student.serialNumber" required>
<div ng-messages="studentForm.serialNumber.$error">
{{studentForm.serialNumber}}
<p ng-message="required">Your name is required!</p>
</div>
<!--</div>-->
<div>
<label>Name: {{student.name}}</label>
<input ng-model="student.name" placeholder="name">
</div>
<div>
<label>Group number: {{student.groupNumber}}</label>
<input ng-model="student.groupNumber" placeholder="groupNumber">
</div>
<button (click)="goBack()">Back</button>
<button (click)="save()">Save</button>
</form>
</div>
</div>
The ng-messages and ng-model attribute directives do not exist in Angular 2+. I would recommend reading into Angular Forms, ReactiveForms, and Template Syntax.
If you would like to dual data-bind the input values, you can do so with the following syntax: [(ngModel)]="student.serialNumber". However, in Angular 2+, there are usually better ways of getting values other than explicitly data-binding.
Angular Form Validation template Driven Model
onSubmit(form : NgForm) {
console.log(form);
}
<form #form="ngForm" (ngSubmit)="onSubmit(form)"
[ngClass]="{'was-validated': form.invalid && (form.dirty || form.touched)}">
<div class="" ngModelGroup="User">
<h2 class="text-center">Registration page</h2>
<br />
<div class="form-group">
<input type="text" class="form-control" placeholder="First Name" name="firstname" required
ngModel #firstname="ngModel">
<span class="help-bpx" *ngIf="firstname.touched && !firstname.valid ">Please enter the
firstname</span>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Last Name" name="lastname" required ngModel
#lastname="ngModel">
<span class="help-bpx" *ngIf="lastname.touched && !lastname.valid ">Please enter the
lastname</span>
</div>
<div class="form-group">
<input type="email" class="form-control" id="email" placeholder="Email" name="email" email
required ngModel #email="ngModel">
<span class="help-bpx" *ngIf="email.touched && !email.valid ">Please enter the Email
Value</span>
</div>
<div class="form-group">
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFile" required ngModel name="file" #file="ngModel">
<label class="custom-file-label" for="customFile">Choose file</label>
</div>
</div>
<br />
<div class="align-center">
<button type="submit" class="btn btn-primary" [disabled]="!form.valid">Register</button>
</div>
</div>
</form>

jQuery Mobile dialog with form: after submitting $_POST is empty

I have a problem reading the $_POST data after i submitted a form from a dialog.
The setup is like this:
Page1 (clientcard.php) contains a link to a dialog:
Add new contact...
Page 2 (the addcontact.php) posts the data to clientcard.php:
<h3 style="margin-top: 0px;">Create contact</h3>
<form method="POST" name="formaddcontact" id="formaddcontact" action="clientcard.php">
<input type="hidden" name="client_ref" value="<?php echo $id;?>" />
<input type="hidden" name="mode" value="addcontact" />
<ul data-role="listview" data-inset="true">
<li class="ui-field-contain">
<label for="naam">name:</label>
<input name="naam" id="naam" value="" data-clear-btn="false" type="text" />
</li>
<li class="ui-field-contain">
<label for="functie_ref">Department:</label>
<select name="functie_ref" id="functie_ref" data-native-menu="false">
<!-- some options -->
</select>
</li>
<li class="ui-field-contain">
<label for="telefoon">Phone:</label>
<input name="telefoon" id="telefoon" value="" data-clear-btn="false" type="text" />
</li>
<li class="ui-field-contain">
<label for="mobiel">Cell:</label>
<input name="mobiel" id="mobiel" value="" data-clear-btn="false" type="text" />
</li>
<li class="ui-field-contain">
<label for="email">Email:</label>
<input name="email" id="email" value="" data-clear-btn="false" type="text" />
</li>
<li class="ui-body ui-body-b">
<fieldset class="ui-grid-a">
<div class="ui-block-a">Annuleren</div>
<div class="ui-block-b">Opslaan</div>
</fieldset>
</li>
</ul>
</form>
I read in other answers that you have to use something like parent().appendTo($("form:first"));but to be honest i have NO clue where to put that...
I use jquery mobile 1.4.3 and the jquery code that is actually popping up the dialog is generated by jqm and i have no <script> code whatsoever in my files...
Any help would be greatly appreciated.
Regards, Christiaan

Form GET and redirect possible?

I am having trouble figuring out how to set the form to submit a string to an affiliate but also redirecting the user to my own hosted thank you page. I am using the GET method to submit the string.
this is a very dumbed down version of my form
<form action="http://xxxxx.com/api/post.ashx" method="get">
<div>
<label ><span>First Name <font style="color: red;">*</font></span></label>
<input type="text" name="First" value="" maxlength="128" class="form-text required" />
</div>
<div >
<label ><span>Last Name <font style="color: red;">*</font></span></label>
<input type="text" name="Last" value="" size="60" maxlength="128" class="form-text required" />
</div>
<div >
<label ><span>Phone Number <font style="color: red;">*</font></span></label>
<input class="form-text" type="text" maxlength="14" name="phone1" id="phone1" value="">
</div>
</div>
<input class="form-submit" type="submit" id="edit-submit" name="op" value="Submit" />
</div></form>
If I understand your problem right, iframe is a kinda solution here.

I have two forms on a page but the submit button is submitting both forms

Hi I have two forms on a page, one is a small newsletter sign up form and the other is a larger event booking form. when the large booking form is submitted it submits the small newsletter form aswell. think it has something to do with the action url.
Here is the page code:
<script type="text/javascript"><!--
function validate(f){
var regex = /^\s*$/i;
for(var i=0; i<f.elements.length; i++){
if(regex.test(f.elements[i].value)){
alert("Please fill in all fields.");
f.elements[i].focus();
return false;
}
}
if(f.user_email.value.indexOf('#',0)==-1 || f.user_email.value.indexOf('.',0)==-1)
{
alert("You must provide a VALID email address.");
f.user_email.focus();
return false;
}
return true;
}
//--></script>
<div id="eventform" />
<form action="/Booking?ename=testevent&edate=19%20October%202011&submitform=yes" method="post" onsubmit='return validate(this);'>
<fieldset class="fieldset">
<div class="leftform">
<label for="booking_name">Event: </label><br class="nobr" />
<input name="booking_name" type="text" id="booking_name" value="testevent" />
</div>
<div class="rightform">
<label for="event_date">Date: </label><br class="nobr" />
<input name="event_date" type="text" id="event_date" value="19 October 2011" />
</div>
<div class="clear"></div>
<div class="leftform">
<label for="user_name">Name: </label><br class="nobr" />
<input name="user_name" type="text" id="user_name" />
</div>
<div class="rightform">
<label for="organisation">Organisation: </label><br class="nobr" />
<input name="organisation" type="text" id="organisation" />
</div>
<div class="clear"></div>
<div class="leftform">
<label for="address">Address: </label><br class="nobr" />
<input name="address" type="text" id="address" />
</div>
<div class="rightform">
<label for="postcode">Postcode: </label><br class="nobr" />
<input name="postcode" type="text" id="postcode" />
</div>
<div class="clear"></div>
<div class="leftform">
<label for="user_telephone">Contact Number: </label><br class="nobr" />
<input name="user_telephone" type="text" id="user_telephone" />
</div>
<div class="rightform">
<label for="user_email">Email Contact: </label><br class="nobr" />
<input name="user_email" type="text" id="user_email" />
</div>
<div class="clear"></div>
<br />
<hr />
<h3>Attendees</h3>
<p>Please list the name(s) and email address(s) of those you wish to book a place at the above event.</p>
<div class="leftform">
<input placeholder="Name" name="attendee1" type="text" id="attendee1" />
</div>
<div class="rightform">
<input placeholder="Email Address" name="attendee_email1" type="text" id="attendee_email1" />
</div>
<div class="clear"></div>
<div class="leftform">
<input placeholder="Name" name="attendee2" type="text" id="attendee2" />
</div>
<div class="rightform">
<input placeholder="Email Address" name="attendee_email2" type="text" id="attendee_email2" />
</div>
<div class="clear"></div>
<div class="leftform">
<input placeholder="Name" name="attendee3" type="text" id="attendee3" />
</div>
<div class="rightform">
<input placeholder="Email Address" name="attendee_email3" type="text" id="attendee_email3" />
</div>
<div class="clear"></div>
<div class="leftform">
<input placeholder="Name" name="attendee4" type="text" id="attendee4" />
</div>
<div class="rightform">
<input placeholder="Email Address" name="attendee_email4" type="text" id="attendee_email4" />
</div>
<div class="clear"></div>
<div class="leftform">
<input placeholder="Name" name="attendee5" type="text" id="attendee5" />
</div>
<div class="rightform">
<input placeholder="Email Address" name="attendee_email5" type="text" id="attendee_email5" />
</div>
<div class="clear"></div>
<br />
<hr />
<h3>Invoice Details</h3>
<p>Please give details of where the invoice should be sent.</p>
<label for="invoice_name">Name: </label><br class="nobr" />
<input name="invoice_name" type="text" id="invoice_name" /><br />
<label for="invoice_address">Address: </label><br class="nobr" />
<input name="invoice_address" type="text" id="invoice_address" /><br />
<label for="invoice_postcode">Postcode: </label><br class="nobr" />
<input name="invoice_postcode" type="text" id="invoice_postcode" /><br />
<p>Once we have received your booking form the person booking and those attending will receive a confirmation email confirming your places at the event and an invoice will be issued.
If you have any questions please do not hesitate to contact.</p>
</fieldset>
<br />
<input id="bookingform_submit" class="submitform" type="submit" value="Submit" />
<br /><br />
</form>
</div>
</div>
</div>
<div class="clear"></div>
</div></div>
<!--/content-->
<!--footer-->
<div id="outer-footer">
<div id="footer">
<div class="footer-1">
<h6>Get in touch...</h6>
<ul>
<li>Suite 124-128 Baltic Chambers,50 Wellington Street Glasgow G2 6HJ.</li>
<li><span>Tel:</span> 0141 248 1242</li>
<li><span>Fax:</span> 0141 221 1911</li>
<li><span>Email Us:</span>info#tis.org.uk </li>
</ul>
</div>
<div class="footer-2">
<h6>Join our newsletter...</h6>
<ul>
<li>Hear about the latest event and courses.</li>
<script type="text/javascript"><!--
function validate(f){
var regex = /^\s*$/i;
for(var i=0; i<f.elements.length; i++){
if(regex.test(f.elements[i].value)){
alert("Please fill in all fields.");
f.elements[i].focus();
return false;
}
}
if(f.user_email.value.indexOf('#',0)==-1 || f.user_email.value.indexOf('.',0)==-1)
{
alert("You must provide a VALID email address.");
f.user_email.focus();
return false;
}
return true;
}
//--></script>
<li>
<form action="./&submitform=yes" method="post">
<span class="input_space">
<input name="user_name" id="user_name" type="text" align="left" onblur="if(this.value=='')this.value='Your Name';"
onfocus="if(this.value=='Your Name')this.value='';" value="Your Name" />
</span>
<span>
<input name="user_email" id="user_email" type="text" align="left" onblur="if(this.value=='')this.value='Your Email Address';"
onfocus="if(this.value=='Your Email Address')this.value='';" value="Your Email Address" />
</span>
<input id="newsletterform_submit" type="submit" value="" class="submit-2" />
</form>
I dont think it is submitting the form twice, i think that the variable "submitform" = yes is being set by both, so when you click through to the large form it thinks that form 2 has been submitted also - but in reality it hasn't... you probably want to check that the form has really been submitted using the $_POST variables.

PHP Image Upload Problem

Getting Undefined index: filename error in the below image upload php code. Is there any problem in the below code?
<div id="content">
<form class="wufoo" action=<?php echo (BASE_PATH. 'admin/addbusinessdetail'); ?> method="post">
<input type="hidden" name="maxSize" value="9999999999" />
<input type="hidden" name="maxW" value="200" />
<input type="hidden" name="fullPath" value="<?php echo (BASE_PATH. 'public/img/uploads/'); ?>" />
<input type="hidden" name="relPath" value="<?php echo (BASE_PATH. 'public/img/uploads/'); ?>" />
<input type="hidden" name="colorR" value="255" />
<input type="hidden" name="colorG" value="255" />
<input type="hidden" name="colorB" value="255" />
<input type="hidden" name="maxH" value="300" />
<ul>
<li>
<label class="desc">Business Type</label>
<br />
<div>
<select class="field select" name="ddltype" style="width:300px; height: 30px;">
<?php
$types = $this->_data;
foreach ($types as $value) {
foreach($value as $innvalue){
$businessname[] = $innvalue;
}
echo('<option value="'.$businessname[0].'">'.$businessname[1].'</option>');
unset($businessname);
}
?>
</select>
</div>
</li>
<li>
<label class="desc">Business Detail <span class="req">*</span></label>
<br />
<div>
<input type="text" class="field text" name="businessname" style="width: 300px; height: 20px;" />
</div>
</li>
<li>
<label class="desc">Business Website <span class="req">*</span></label>
<br />
<div>
<input type="text" class="field text" name="website" style="width: 300px; height: 20px;" />
</div>
</li>
<li>
<label class="desc">Business Email <span class="req">*</span></label>
<br />
<div>
<input type="text" class="field text" name="email" style="width: 300px; height: 20px;" />
</div>
</li>
<li>
<label class="desc">Business Image <span class="req">*</span></label>
<br />
<div>
<input type="file" name="filename" />
</div>
</li>
<li>
<label class="desc">Address <span class="req">*</span></label>
<br />
<div>
<textarea name="address" cols="50" rows="8" ></textarea>
</div>
</li>
<li class="buttons">
<input class="submit" type="submit" value="Save" /> <input class="submit" type="button" value="Cancel" onClick="history.back()" />
</li>
</ul>
</form>
addbusinessdetail controller
function addbusinessdetail()
{
print_r($_FILES['filename']);
$this->Admin->addbusinessdetail();
$this->businessdetails(0,0);
}
add this to your form tag:
enctype="multipart/form-data"
If you're doing a file upload, you need this form attribute so the web server knows to expect file data.Here's some more info on file uploads: http://www.tizag.com/phpT/fileupload.php