jquery Validate not validating input in IE 8 - jquery-validate

I am using jquery validation and it is not catching instances where the validation conditions are not met? This is curious to me, partly, because it was working before (I am using IE 8 in compatibility mode now, would that affect something?)...
There don't seem to be any compilation exceptions off the top of my head? Does where I import the jquery validation src file affect how it works??? Here is my code...
$("#temp1").validate({
rules: {
HospitalFinNumber: {
required: true,
minlength: 6
},
DateOfBirth: {
required: true
},
AdmitDate: {
required: true
},
Comment: {
required: function (element) {
return $(element).val().length < 4000;
},
maxlength: 4000
}
},
messages: {
HospitalFinNumber: 'Please Enter a Hospital Fin number',
DateOfBirth: 'Please enter a valid Date Of Birth',
AdmitDate: 'Please select an Admit Date',
Comment: 'Why dont you stop attempting to put in more than 4000 characters? Thanks...'
}
});
Here are my includes into source...
<script src="<%=Url.Content("~/Scripts/js/jquery-ui-1.8.15.custom.min.js")%>" type="text/javascript"></script>
<script src="<%=Url.Content("~/Scripts/jquery.validate.min.js")%>" type="text/javascript"></script>
<script src="<%=Url.Content("~/Scripts/jquery.timeentry.min.js")%>" type="text/javascript"></script>
<script src="<%=Url.Content("~/Scripts/jquery.maskedinput-1.3.min.js")%>" type="text/javascript"></script>
<script src="<%=Url.Content("~/Scripts/charCount.js")%>" type="text/javascript"></script>
<script src="<%=Url.Content("~/Scripts/jquery.filter_input.js")%>" type="text/javascript"></script>
<script src="<%=Url.Content("~/Scripts/simpleTimeMask.js")%>" type="text/javascript"></script>
form elements:
<div class="edit-set" id="EditTemplate">
<form action="/PatientACO/UpdateXML?template=592&PopPatId=1139&EncOrAdd=0" id="temp1" method="post" name="editTemp"><div class="validation-summary-valid" id="validationSummary"><ul><li style="display:none"></li>
</ul></div>
Activate/Deactivate Patient
<div id="deactivateNO" style="display:none"><input id="deactivate" name="deactivate" type="radio" value="N" />Deactivate</div>
<div id="deactivateYES" style="display:none"><input id="deactivate" name="deactivate" type="radio" value="A" />Activate</div>
<table width="500" class="odd"><tr><td><label for="BLUE">First Name</label></td><td> <input id="element6" name="FirstName" readonly="True" type="text" value="BLUE" /></td></tr> <tr><td><label for="CRAYON">Last Name</label></td><td><input id="element7" name="LastName" readonly="True" type="text" value="CRAYON" /></td></tr><tr><td><label for="10/31/1966 12:00:00 AM">Date Of Birth</label></td><td><input class="datepicker0" id="date0" name="DateOfBirth" type="text" value="10/31/1966" /><!--supposed to be date input --></td></tr><tr><td><label for="4111111111">Phone</label></td><td><input id="Phone" name="Phone" type="text" value="4111111111" /><!--string input -->
</td></tr><tr><td><label for="111 222 333 444">Hospital Fin Number (**required**)</label></td><td><input id="HospitalFinNumber" name="HospitalFinNumber" type="text" value="" /><!--string input -->
</td></tr><tr><td><label for="29-DEC-11">Admit Date (**required**)</label></td><td><input class="datepicker1" id="AdmitDate" name="AdmitDate" type="text" value="" /><!--supposed to be date input -->&nbsp</td></tr><tr><td><label for="MPACMRN">MRN Type</label></td><td><select id="MPACMRN" name="MRNType"><option selected="selected" value="MPACMRN">Medipac</option>
<option value="NWMRN">NorthWest</option>
<option value="EPIC">Epic</option>
<option value="BEDFORD">Bedford</option>
<option value="CHILDRENS">Childrens</option>
<option value="MAGEE">Magee</option>
<option value="PASSAVANT">Passavant</option>
<option value="MERCY">Mercy</option>
<option value="BEST">Medicare</option>
<option value="HEALTHPLAN">UPMC Health Plan</option>
<option value="EMPIID">EMPI</option>
</select></td></tr><tr><td><label for="840015579">MRN</label></td><td><input id="MRN" name="MRN" type="text" value="840015579" /></td></tr><tr><td><label for="">Patient Room Phone</label></td><td><input id="PatientRoomPhone" name="PatientRoomPhone" type="text" value="" /><!--string input -->
</td></tr><tr><td><label for="">Discharge Date Time</label></td><td><input class="datepicker2" id="DischargeDateTime" name="DischargeDateTime" type="text" value="" /><!--supposed to be date input -->&nbsp<input id="DischargeDateTimeMask" name="DischargeDateTimeMask" type="text" value="" /><!--supposed to be date input --></td></tr><tr><td><label for="">Discharge Disposition</label></td><td><input id="DischargeDisposition" name="DischargeDisposition" type="text" value="" /><!--string input -->
</td></tr><tr><td><label for="">Discharge To</label></td><td><input id="DischargeTo" name="DischargeTo" type="text" value="" /><!--string input -->
</td></tr><tr><td><label for="1">Discharge Advocate Call</label> </td><td><input checked="checked" id="element18" name="DischargeAdvocateCall" type="radio" value="1" />Yes<input id="element18" name="DischargeAdvocateCall" type="radio" value="0" />No</td></tr><tr><td><label for="">Payor</label></td><td><input id="Payor" name="Payor" type="text" value="" /><!--string input -->
</td></tr><tr><td><label for="1">Home Healthcare Accepted</label> </td><td><input checked="checked" id="element20" name="HomeHealthCareAccepted" type="radio" value="1" />Yes<input id="element20" name="HomeHealthCareAccepted" type="radio" value="0" />No</td></tr><tr><td><label for="1">Safe Landing Accepted</label></td><td><input checked="checked" id="element21" name="SafeLandingAccepted" type="radio" value="1" />Yes<input id="element21" name="SafeLandingAccepted" type="radio" value="0" />No</td></tr> <tr><td><label for="">PCP Name</label></td><td><input id="PCPName" name="PCPName" type="text" value="" /><!--string input -->
</td></tr><tr><td><label for="">PCP Phone</label></td><td><input id="PCPPhone" name="PCPPhone" type="text" value="" /><!--string input -->
</td></tr><tr><td><label for="">Specialist Name</label></td><td> <input id="SpecialistName" name="SpecialistName" type="text" value="" /><!--string input -->
</td></tr><tr><td><label for="">Specialist Phone</label></td><td> <input id="SpecialistPhone" name="SpecialistPhone" type="text" value="" /><!--string input -->
</td></tr><tr><td><label for="">PCP Appointment Date Time</label> </td><td><input class="datepicker3" id="PCPAppointmentDateTime" name="PCPAppointmentDateTime" type="text" value="" /><!--supposed to be date input -->&nbsp<input id="PCPAppointmentDateTimeMask" name="PCPAppointmentDateTimeMask" type="text" value="" /><!--supposed to be date input --></td></tr><tr><td><label for="">PCP Appointment Location</label></td><td><input id="PCPAppointmentLocation" name="PCPAppointmentLocation" type="text" value="" /><!--string input -->
</td></tr><tr><td><label for="">Specialist Appointment Date Time</label></td><td><input class="datepicker4" id="SpecialistAppointmentDateTime" name="SpecialistAppointmentDateTime" type="text" value="" /><!--supposed to be date input -->&nbsp<input id="SpecialistAppointmentDateTimeMask" name="SpecialistAppointmentDateTimeMask" type="text" value="" /><!--supposed to be date input --></td></tr><tr><td><label for="">Specialist Appointment Location</label></td><td><input id="SpecialistAppointmentLocation" name="SpecialistAppointmentLocation" type="text" value="" /><!--string input -->
</td></tr><tr><td><label for="">Completed Pathway</label></td><td><input id="element30" name="CompletedPathway" type="radio" value="1" />Yes<input id="element30" name="CompletedPathway" type="radio" value="0" />No</td></tr><tr><td><label for="">Completed Pathway Reason</label></td><td><input id="CompletedPathwayReason" name="CompletedPathwayReason" type="text" value="" /><!--string input -->
</td></tr><tr><td><label for="Testing the Add function on my development setup.">Comment</label></td><td><textarea cols="60" id="element32" name="Comment" rows="10">
</textarea></td></tr></table>
<p>
<input type="submit" value="Save" class="button" id="btClick"/>
</p>
</div>
</form>
Also, I just noticed that it is not working in ie 8 but it is working in chrome? Could there be some browser compatibility problems?

Jquery Validate version 1.9 seems to have fixed the problem...
Link to version 1.9
I had to add it to my project as a package. Which I find is weird. But what the heck ever.

Related

ON BLUR IS NOT WORKING

<input type="email" class="form-control" id="email" placeholder="Enter
email" name="email" onblur="validation()">
<input type="text" name="war-email" id="war-email" value=""
class="error" readonly hidden/><br>
<input type="password" class="form-control" id="pwd"
placeholder="Enter password" name="pwd" onblur="validation()">
<input type="text" name="war-pas" id="war-pas" value="" class="error"
readonly hidden/><br>
<input type="cpassword" class="form-control" id="cpwd"
placeholder="Enter password" name="cpwd" onblur="validation()">
<input type="text" name="war-cpas" id="war-cpas" value=""
class="error" readonly hidden/><br>
<script>
function validation(){
if(document.getElementById("email").value==""){
$("#war-email").show();
document.getElementById("war-email").value="this is invalid email";
document.getElementById("war-email").style.color="red";
}else{
document.getElementById("war-email").value="this is valid email";
document.getElementById("war-email").style.color="green";
}
if(document.getElementById("pwd").value==""){
$("#war-pas").show();
document.getElementById("war-pass").value="Short password";
document.getElementById("war-pas").style.color="red";
}else{
document.getElementById("war-pas").value="Strong password";
document.getElementById("war-pas").style.color="green";
}
var len=document.getElementById("cpwd").value;
if(document.getElementById("pwd").value!=
document.getElementById("cpwd").value==)
{
$("#war-cpas").show();
document.getElementById("war-cpass").value="Both password should
matched";
document.getElementById("war-cpas").style.color="red";
}else{
document.getElementById("war-cpas").value="matched..!!";
document.getElementById("war-cpas").style.color="green";
}
}
</script>
First of all, put your code in a snippet so it will be easier for us to understand. Anyway, I'll tell how to attach blur event using jQuery.
$("input#name").on("blur", function()
{
if(!this.value)
{
alert("Please fill out the name");
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<form id="myForm">
<label>Your Name</label>
<input type="text" id="name">
</form>
If you need any other help, just let me know :-)

Validating Arrays of radio buttons in laravel

I am using Laravel 5.1 and homestead.
My issue is when validation fails, the radio buttons do not repopulate with data from the original user's input.
My validation rules from PostRequest.php
public function rules()
{
//validating input text field --> this one works
$rules = ['owner' => 'required|max:15',];
//validating array of input text fields --> this too works
foreach($this->request->get('item') as $a => $z)
{
$rules['item.'.$a] = 'required';
}
//validating array of radio buttons --> does not return with data
foreach($this->request->get('radio') as $b => $y)
{
$rules['radio.'.$b] = 'required';
}
return $rules;
}
A segment of my view(blade.php)
<div class="row">
<div class="tcell col-xs-6">
<label for="item[0]" class="sr-only"></label>
<input class="form-control" id="item[0]" name="item[0]" type="text" placeholder="enter item" value="{ { old('item.0') } }"/>
</div>
<div class="tcell col-xs-6">
<div class="radio">
<input type="radio" id="s15" name="radio[0]" value="5" /><label for="s15" title="5">5</label>
<input type="radio" id="s14" name="radio[0]" value="4" /><label for="s14" title="4">4</label>
<input type="radio" id="s13" name="radio[0]" value="3" /><label for="s13" title="3">3</label>
<input type="radio" id="s12" name="radio[0]" value="2" /><label for="s12" title="2">2</label>
<input type="radio" id="s11" name="radio[0]" value="1" /><label for="s11" title="1">1</label>
</div>
</div>
</div>
...
<div class="tcell col-xs-6">
<div class="radio">
<input type="radio" id="s20" name="radio[1]" value="5" /><label for="s20" title="5">5</label>
<input type="radio" id="s19" name="radio[1]" value="4" /><label for="s19" title="4">4</label>
<input type="radio" id="s18" name="radio[1]" value="3" /><label for="s18" title="3">3</label>
<input type="radio" id="s17" name="radio[1]" value="2" /><label for="s17" title="2">2</label>
<input type="radio" id="s16" name="radio[1]" value="1" /><label for="s16" title="1">1</label>
</div>
</div>
The old() function worked for both input(text) and array of input(text). but I do not know how to apply it with radio buttons.
Thanks
Here's the solution
<input type="radio" id="s15" name="radio[1]" value="5" { { old('radio.1')=="5" ? 'checked='.'"'.'checked'.'"' : '' } } /><label for="s15" title="5">5</label>
<input type="radio" id="s14" name="radio[1]" value="5" { { old('radio.1')=="4" ? 'checked='.'"'.'checked'.'"' : '' } } /><label for="s14" title="4">4</label>
...
This will only help redirect back with the inputed data, however, validation will still fail if nothing is selected since nothing gets submitted. The fix is to use for loop instead of foreach loop. You must get the count of the radio buttons to iterate.
try to amend as following
blade template:
<div class="radio">
<input type="radio" id="s15" name="radio" value="5" /><label for="s15" title="5">5</label>
<input type="radio" id="s14" name="radio" value="4" /><label for="s14" title="4">4</label>
<input type="radio" id="s13" name="radio" value="3" /><label for="s13" title="3">3</label>
<input type="radio" id="s12" name="radio" value="2" /><label for="s12" title="2">2</label>
<input type="radio" id="s11" name="radio" value="1" /><label for="s11" title="1">1</label>
</div>
Form request
public function rules()
{
//validating input text field --> this one works
$rules = ['owner' => 'required|max:15', 'radio' => 'required'];
//validating array of input text fields --> this too works
foreach($this->request->get('item') as $a => $z)
{
$rules['item.'.$a] = 'required';
}
return $rules;
}

Chrome removes form tag in .innerHTML insert

I have some mvc frameworks that extend my .net application. Their task is mainly to deliver partials to the .net applications interface.
The funny thing is that chrome strips the very necessary
Here is how I fetch and render the data from the framework
$.ajax({
url: "/mvc/UserProfile/AddressForm?datatype=shipping",
dataType: "text", // text html script
method: "get",
cache: false,
success: function (data) {
console.log(data);
//var userProfileAdd = document.getElementById("userProfileAdd");
var userProfileAdd = $("#userProfileAdd")[0];
userProfileAdd.innerHTML = "<div>" + data + "</div>";
}
});
Firefox, IE and so on does retrieve all data. Does anyone know why chrome behaves like this?
Thanks
EDIT
This is the code sent to the data variable printed by console.log
<script src="/scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
<form OnSubmit="return false;" action="/mvc/UserProfile/AddressFormPost" id="frmUserAddress" method="post"><div class="validation-summary-valid" id="validationSummary"><ul><li style="display:none"></li>
</ul></div>
<input name="__RequestVerificationToken" type="hidden" value="8Vkd039Wc3825G6CTEomJ/aXfrCyjuEY3sV/ty4znHi9yO0Th535p8VNxqvBwhJ12AREQhvTMhRVNEO6Ke3O87jDAjREg3I3dFYp2Y5geutbEOLk6KHmn6hLb4a5CFaZ3uCOm8uYgr/U4au33yaUFw==" />
<div>
Select country:
<select id="Countries" name="Countries"><option value="029">Caribbean</option>
<option value="AE">U.A.E.</option>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="AM">Armenia</option>
<option value="AR">Argentina</option>
</select>
</div>
<div>
Postal Code
<input class="formField textBox" id="PostalCode" name="PostalCode" type="text" value="" />
<span class="field-validation-valid" id="PostalCode_validationMessage"></span>
</div>
<div>
City
<input class="formField textBox" id="City" name="City" type="text" value="" />
<span class="field-validation-valid" id="City_validationMessage"></span>
</div>
<div>
State
<input class="formField textBox" id="State" name="State" type="text" value="" />
<span class="field-validation-valid" id="State_validationMessage"></span>
</div>
<div>
First name
<input class="formField textBox" id="FirstName" name="FirstName" type="text" value="" />
<span class="field-validation-valid" id="FirstName_validationMessage"></span>
</div>
<div>
Email
<input class="formField textBox" id="Email" name="Email" type="text" value="" />
<span class="field-validation-valid" id="Email_validationMessage"></span>
</div>
<div>
<input type="submit" value="Send!" id="btnAddressForm" class="button" />
</div>
</form><script type="text/javascript">
//<![CDATA[
if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; }
window.mvcClientValidationMetadata.push({"Fields":[{"FieldName":"PostalCode","ReplaceValidationMessageContents":true,"ValidationMessageId":"PostalCode_validationMessage","ValidationRules":[{"ErrorMessage":"Please enter your postal code","ValidationParameters":{},"ValidationType":"required"}]},{"FieldName":"City","ReplaceValidationMessageContents":true,"ValidationMessageId":"City_validationMessage","ValidationRules":[{"ErrorMessage":"Please enter your city","ValidationParameters":{},"ValidationType":"required"}]},{"FieldName":"State","ReplaceValidationMessageContents":true,"ValidationMessageId":"State_validationMessage","ValidationRules":[{"ErrorMessage":"Please enter your state","ValidationParameters":{},"ValidationType":"required"}]},{"FieldName":"FirstName","ReplaceValidationMessageContents":true,"ValidationMessageId":"FirstName_validationMessage","ValidationRules":[{"ErrorMessage":"Please enter your first name","ValidationParameters":{},"ValidationType":"required"}]},{"FieldName":"Email","ReplaceValidationMessageContents":true,"ValidationMessageId":"Email_validationMessage","ValidationRules":[{"ErrorMessage":"Please enter your first name","ValidationParameters":{},"ValidationType":"required"}]}],"FormId":"frmUserAddress","ReplaceValidationSummary":false,"ValidationSummaryId":"validationSummary"});
//]]>
</script>
Chrome will strip out the form element if there is a surrounding form element. JUST the form tag disappears, all of its contents remain.
Check to make sure that there isn't a parentNode for "userProfileAdd" that is a form.

Paypal form submission - mobile

Im using below code to submit values in to Paypal and its working.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<h2 style="font-family:Segoe UI;">Your Email :</h2>
<input type="text" name="business" value="youremailaddress#yourdomain.com" style="width:1000px; height:50px; margin-left:30px;"/>
<br />
<h2 style="font-family:Segoe UI;">Driveway Size :</h2>
<input type="hidden" name="item_name" value="" />
<select id="item_price" name="amount" style="width:1000px; height:50px; margin-left:30px;">
<option value="325">Single $325.00</option>
<option value="375">Double $375.00</option>
<option value="400">2.5 $400.00</option>
<option value="425">Triple $425.00</option>
<option value="450">3.5 $450.00</option>
<option value="475">Quad $475.00</option>
</select>
<br />
<input type="submit" value="Buy!" style="margin-top:30px"/>
</form>
But this is desktop version. is there anyway that I can do same thing for mobiles?
Yes you can. You could for example use System.Net.WebClient to make the post towards the URL you have in the action field of the form.
Or, you can have the above HTML code embedded inside a web-browser control in your application.

Editing Magento Checkout Form

On clicking "place order" in Magento, I want to capture some of its values and feed them to the following form:
<form method="post" action="https://www.jambopay.com/JPExpress.aspx" target="_blank">
<input type="hidden" name="jp_item_type" value="cart"/>
<input type="hidden" name="jp_item_name" value="test shop"/>
<input type="hidden" name="order_id" value="455879"/>
<input type="hidden" name="jp_business" value="business#yourdomain.com"/>
<input type="hidden" name="jp_amount_1" value="51"/>
<input type="hidden" name="jp_amount_2" value="0"/>
<input type="hidden" name="jp_amount_5" value="0"/>
<input type="hidden" name="jp_payee" value="email#yourcustomer.com"/>
<input type="hidden" name="jp_shipping" value="company name"/>
<input type="hidden" name="jp_rurl" value="http://www.yourwebsite.com/testpost/Result.aspx?ii=0"/>
<input type="hidden" name="jp_furl" value="http://www.yourwebsite.com/testpost/Result.aspx?ii=1"/>
<input type="hidden" name="jp_curl" value="http://www.yourwebsite.com/testpost/Result.aspx?ii=2"/>
<input type="image" src="https://www.jambopay.com/jambohelp/jambo/rsc/paymentsbyJamboPay.jpg"/>
</form>
The values include:
Order Number,
Total Amount,
Customers Email Address,
How do i do this?
You can get value of order after save order is called you can get last order id from this methods
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
once you have order id then load order like this
$order = Mage::getModel('sales/order')->load($orderId);
and you can get all details of order

Resources