Kindle Silk browser having issues with keypress event? - asp.net-mvc-4

I'm trying to restrict a text box to numeric entry only in a project using knockout.js and MVC.
I'm doing a data-bind on the keypress event to call a function from the VM that looks like this:
this.NumbersOnly = function (data,evt) {
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode != 46 && (charCode < 48 || charCode > 57)))
return false;
return true;
}
This will allow only numbers and decimals in to the input text box. This works great in every browser I've tested except that I'm having issues in Kindle's Silk browser, as I can still type alpha characters in. If anyone has any ideas to get Silk to agree, please let me know!

Related

best way to change download link based on an input field?

I program in C (embedded programming) but have no experience for web-based stuff. I have a need to download a different link based on an input field.
input serial number in field.
click download link
if serial number = a,b,c etc.. download file_version_a
else if serial number = e,f,g, etc.. download file_version_b
what is the best script language to use to for something like this? I've searched all over and haven't found much that seems relevant and don't know where to start.
You could use something like below in your html page :
<input type="text" id="serialnumbers" name="serialnumbers"></input>
<input type="button" id="download" name="download" onclick="downloadlink();return false;"value="Download Now"></input>
<script>
function downloadlink(){
var serialnos=document.getElementById('serialnumbers').value;
serialnos = serialnos.trim();
if( serialnos == "a" || serialnos == "b" || serialnos == "c" )
window.location = download file_version_a;
}
else if( serialnos == "e" || serialnos == "f" || serialnos == "g" )
window.location = download file_version_b;
}
</script>
Also,some suggestions for the same would be to check Jquery,very convenient Javascript library ,Refer Doc :https://jquery.com/

How to capture "#" and "#" key pressed - Silverlight Textbox Keyup Event

I wrote below code for capturing "#" and "#" pressed or not. And working perfectly fine on Emulator and Samsung Focus. But when deploy to Nokia Lumia 800 and pressed "#" it wont resulted in Key.D2 and below code not working.
if (e.Key == System.Windows.Input.Key.D2)
{
myAutocompleteBox.Text = "#";
updateAutocompleteBox = true;
}
else if (e.Key == System.Windows.Input.Key.D3)
{
myAutocompleteBox.Text = "#";
updateAutocompleteBox = true;
}
else if (e.Key == System.Windows.Input.Key.Back)
{
if (myAutocompleteBox.Text != String.Empty && updateAutocompleteBox == true)
{
string autoCompleteText = myAutocompleteBox.Text;
myAutocompleteBox.Text = autoCompleteText.Substring(0, autoCompleteText.Length - 1);
}
}
Please guide me how can i capture "#" and "#" key pressed on my textbox. Thanks in Advance.
I think the value of D2 or D3 depends on the keyboard layout in use. In the EN-US Layout SHIFT+2 is # in DE-DE SHIFT+2 is doublequotes and D0 - D9 are variable based on the layout used. In your code you might have to take that into account when translating the key pressed to the String value.
Have a look at this.
It's got all the Key Enumeration for Windows Phone 7, had a look but couldn't spot # or #.
What value is being returned for e.Key?

are there any keyboard shortcuts for glimpse?

Are there any keyboard shortcuts for glimpse?
I've checked their website http://getglimpse.com/Help and http://getglimpse.com/Help/Configuration as well as the twitter hashtag #glimpse, but I'm getting no love.
I'm looking for something similar to how firebug lite uses F12 to show their console.
There are not currently any keyboard shortcuts for Glimpse.
It is a great idea though - suggest it on the Glimpse User Voice page, or feel free to contribute.
There aren't any currently but I have implemented some of them myself using javascript so our developers could use keyboard shortcuts to turn on/ or star session. Something like
<script type="text/javascript">
$(document).ready(function () {
$(document).keyup(function (event) {
var key = event.keyCode || event.charCode || 0;
if (key == 71 && event.altKey) {
document.cookie = 'glimpseState=On; path=/; expires=Sat, 01 Jan 2050 12:00:00 GMT;';
window.location.reload();
}
else if(key == 83 && event.altKey && event.ctrlKey) {
document.cookie = 'glimpseClientName=' + prompt('Client Name?') + '; path=/; expires=Sat, 01 Jan 2050 12:00:00 GMT;';
window.location.reload();
}
});
});
</script>

Adobe 9 Check box required field

I've created reports in Adboe that have checkobxes and set then to required fields.
But when i click the submit button all fields but the check boxes are validated.
I.e
If i dont complete the required textbox field the report will not submit, but when i do and the required checkbox fields are not checked it still submits.
This only appears to be happening on Adobe 9
Any ideas?
Thanks
Sp
Here is a link to a test page
http://www.mediafire.com/?mnkmmlime2f
If you fill the text box with anything it will submit regardless of the check box status (which is also a required field)
I have figured it out.
Adobe Reader checkbox allows has a value (default "false") so when the form validates it sees the checkbox as having a value.
I've had to write some java to stop the form submitting if the checkbox has a null/False/false value
This works like a dream
Thanks for trying to help wit hthis post all
var f;
var Valid = "1";
for (var i = 0; i < this.numFields; i++)
{
f = this.getField(this.getNthFieldName(i));
if (f.type == 'checkbox')
{
if(f.required == true)
{
if(f.value == "false" || f.value == "False" || f.value == "null")
{
Valid = "0";
}
}
}
};
if(Valid == "1")
{
this.submitForm('');
}
else
{
app.alert("Please complete all required fields");
}

dojo.keys.HELP - what key is it?

I'm working on context sensitive help in DOJO-based web UI.
such help should be also accessible using keyboard.
this has brought me to dojo.keys.HELP that seems to be created
for such purpose. unfortunately I can't find what key is it:/
in dojo._base.event it's mapped to key code 47 which is '/' ('?').
but after pressing '/':
console.log("current: " + event.keyCode + " / " + event.charOrCode + " target: " + dojo.keys.HELP);
returns:
current: 0 / / target: 47
I've tested most of keys on my keyboard and none has returned event.keyCode equal to dojo.keys.HELP . I'm using DOJO 1.3.1 .
I think you want to just use evt.charCode since charOrCode will return the keyChar (e.g. 'a') first.
For instance, this outputs 47 when I press '/' on my keyboard:
dojo.connect(
dojo.query("html")[0],
"onkeypress",
function(evt) {
console.log( evt.charCode );
}
);
Dojo normalizes the charCode so this is cross-browser compliant.