I have asked to make tweeks to an app created in Ember.js, but I haven't had much experience with it. I have removed/addded fields, added the necessary text, and the one the last tasks to do is validate to fields (phone numbers) to make sure they are identical. It works on my localhost, but it doesn't on the Ember app.
Here is the Ember.js
data.buffer.push("\n </div>\n </div>\n\n <div class=\"form-
row\">\n <div class=\"field w100\">\n <label for=\"primary_phone\">Primary phone (digits only) *</label>\n ");
hashContexts = {'type': depth0,'name': depth0,'required': depth0,'placeholder': depth0,'title': depth0};
hashTypes = {'type': "STRING",'name': "STRING",'required': "STRING",'placeholder': "STRING",'title': "STRING"};
options = {hash:{
'type': ("number"),
'name': ("primary_phone"),
'required': ("required"),
'placeholder': ("e.g. 12025556789 (country code + area code + local number without dashes)"),
'title': ("e.g. 12025556789 (country code + area code + local number without dashes)")
},contexts:[],types:[],hashContexts:hashContexts,hashTypes:hashTypes,data:data};
data.buffer.push(escapeExpression(((stack1 = helpers.input || depth0.input),stack1 ? stack1.call(depth0, options) : helperMissing.call(depth0, "input", options))));
data.buffer.push("\n </div>\n </div>\n\n <div class=\"form-row\">\n <div class=\"field w100\">\n <label for=\"confirm_phone\">Confirm Primary phone (digits only) *</label>\n ");
hashContexts = {'type': depth0,'name': depth0,'required': depth0,'placeholder': depth0,'title': depth0};
hashTypes = {'type': "STRING",'name': "STRING",'required': "STRING",'placeholder': "STRING",'title': "STRING"};
options = {hash:{
'type': ("number"),
'name': ("confirm_phone"),
'required': ("required"),
'placeholder': ("e.g. 12025556789 (country code + area code + local number without dashes)"),
'title': ("e.g. 12025556789 (country code + area code + local number without dashes)")
},contexts:[],types:[],hashContexts:hashContexts,hashTypes:hashTypes,data:data};
data.buffer.push(escapeExpression(((stack1 = helpers.input || depth0.input),stack1 ? stack1.call(depth0, options) : helperMissing.call(depth0, "input", options))));
Here is my jQuery
$(function(){
var $primaryNo = $("input[name='primary_phone']");
var $confirmNo = $("input[name='confirm_phone']");
var $btn = $('#button');
$primaryNo.keypress(function(key) {
if(key.charCode < 48 || key.charCode > 57)
return false;
});
$confirmNo.keypress(function(key) {
if(key.charCode < 48 || key.charCode > 57)
return false;
});
$btn.click(function() {
if ($primaryNo.val() !== $confirmNo.val()) {
alert('The numbers from the Primary Phone field and the Confirm Primary Phone field do not match. Please re-enter');
} else {
return true;
}
});
});
I have conducted some tests with console.log and the Ember app is picking up the .js file I have included, but when I click submit when two different numbers are inserted into the fields, it doesn't alert the user they are incorrect.
Any ideas?
Aucun commentaire:
Enregistrer un commentaire