My issue is very clear and I will go direct to the point.
I have registration form and the user is not allowed to type some characters as (Arabic letter and special characters), So I used JQuery to do that and it worked fine in windows browsers and in iOS browsers but I faced a problem in Android browsers, Here is my code :
$("#NonArabic").keypress(function(event) {
var ew = event.keyCode || event.which;
if (1 <= ew && ew <= 126 && ew != 38)
return true;
return false;
});
$("[name='NationalID']").keypress(function(event) {
var ew = event.which;
if (48 <= ew && ew <= 57 || ew <= 32)
return true;
return false;
});
$("[name='FullName']").keypress(function(event) {
var ew = event.which;
if (47 >= ew || ew >= 58)
return true;
return false;
});
"NoneArabic" is the ID of the form and the others are input fields, the wired thing is that the "NationalID" input field only accepts numbers as you can see the validation and it works fine in all environments (including android browsers), but the "FullName" input field supposed to accept letters only, Although I'm using the same validation way but it's not working in android browsers.
Note: I'm using JSP and Jquery.
So does anyone ever dealt with something like that or know where I went wrong !!
I hope that it's clear and thanks in advance.
Related
I am trying to make a sudoku app, and in it I am generating each puzzle. My generation, I thought, should work flawlessly, yet my app continues to crash. I think it is coming from here and on:
If(_band == 2) {
while((band2.contains(placeholder)) || (band2.get((int)(_stack - 1)).doubleValue() == band1.get((int)(_stack - 1)).doubleValue())) {
placeholder = SketchwareUtil.getRandom((int)(1),(int)(9));
}
band2.add(Double.valueOf(placeholder));
}
This goes from band2 to band9, checking each band before it for a duplicate number in the same position and checking its band for a duplicate number.
If it helps, band3 generation looks like this:
If(_band == 3) {
while((band3.contains(placeholder)) || (band3.get((int)(_stack - 1)).doubleValue() == band1.get((int)(_stack - 1)).doubleValue()) || (band3.get((int)(_stack - 1)).doubleValue() == band2.get((int)(_stack - 1)).doubleValue())) {
placeholder = SketchwareUtil.getRandom((int)(1)), ((int)(9));
}
band3.add(Double.valueOf(placeholder));
}
The error code is always:
Invalid List Operation
: Index: 0, Size: 0
I'm trying to restrict a field to input specific values like only floats, i'm using keypress event to handle it. It is working fine on desktop browser but not working on mobile devices. I'm using android
$(function() {
$(document.body).on('keypress', '.number-only', function (evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
var value = $(this).val();
var dotcontains = value.indexOf(".") != -1;
if (dotcontains){
if (charCode == 46) return false;
}
if (charCode == 46){
return true;
}
if(charCode > 31 && (charCode < 48 || charCode > 57)){
return false;
}
return true;
});
});
I created an app using Unity3D. After developing it for some weeks I tried to generate an apk and test it on my SGII.
Unity returns no errors or warnings when testing the app locally, but when it runs on my phone, it doesn't work.
There are 2 buttons (1 to clock in and 1 to clock out from work). Button 1 takes the date when you clock in, and switches a boolean to allow you to clock out. When running in my phone, button 1 works fine but button 2 doesn't. The button works actually, since it returns every debug.log, but nothing else.
My code looks like this:
function OnGUI()
{
GUI.skin = skin;
if(Functions.firstTime == 0)
{
Functions.setupWiz();
}
switch(currentMenu)
{
case 1:
GUI.BeginGroup(Rect(0, 0, width, height));
if(Functions.birthday == true)
{
debugLog11 = "\n"+happyBirthdayMsg+", "+Functions.userName+"!";
Functions.birthday = false;
}
if(GUI.Button(Rect(buttonTopHMargin,height*.1f + buttonTopVMargin, width*.24f, height*.1f), "ENTRADA", "Box"))
{
if(!clockedIn && clockedOut)
{
var clockIn = Functions.clockIn();
debugLog11 = "\nHora de entrada";
debugLog12 = "\n"+clockIn[3]+":"+clockIn[4]+":"+clockIn[5];
clockedIn = true;
clockedOut = false;
}
else
{
debugLog11 = "\n"+errorMsg1;
debugLog12 = "\n";
}
}
if(GUI.Button(Rect(width - buttonTopHMargin - width*.24f, height*.1f + buttonTopVMargin, width*.24f, height*.1f), "SALIDA", "Box"))
{
if(!clockedOut && clockedIn)
{
// debugLog11 = clockedIn+"\n"+clockedOut;
Functions.clockOut();
var clockOut = Functions.clockOut();
var workedSecondsToday : Array = Functions.calculateDay();
var workedTimeToday = Functions.convertSeconds(parseInt(workedSecondsToday[0].ToString()));
var extraTimeToday = Functions.convertSeconds(parseInt(workedSecondsToday[1].ToString()));
var festTimeToday = Functions.convertSeconds(parseInt(workedSecondsToday[2].ToString()));
if(parseInt(workedSecondsToday[0].ToString()) > 0 && parseInt(workedSecondsToday[1].ToString()) < 1 && parseInt(workedSecondsToday[2].ToString()) < 1)
{
debugLog11 = "\nHora de Salida\nNormal:"; //NORMAL
debugLog12 = "\n"+clockOut[3]+":"+clockOut[4]+":"+clockOut[5]+"\n"+workedTimeToday[1]+":"+workedTimeToday[2]+workedTimeToday[3];
}
else if(parseInt(workedSecondsToday[0].ToString()) > 0 && parseInt(workedSecondsToday[1].ToString()) > 0 && parseInt(workedSecondsToday[2].ToString()) < 1)
{
debugLog11 = "\nHora de Salida\nNormal:\nExtra:"; //NORMAL + EXTRA
debugLog12 = "\n"+clockOut[3]+":"+clockOut[4]+":"+clockOut[5]+"\n"+workedTimeToday[1]+":"+workedTimeToday[2]+workedTimeToday[3]+"\n"+extraTimeToday[0]+"-"+extraTimeToday[1]+":"+extraTimeToday[2]+":"+extraTimeToday[3];;
}
else if(parseInt(workedSecondsToday[0].ToString()) > 0 && parseInt(workedSecondsToday[1].ToString()) < 1 && parseInt(workedSecondsToday[2].ToString()) > 0)
{
debugLog11 = "\nHora de Salida\nNormal:\nFestivo:"; //NORMAL + FESTIVO
debugLog12 = "\n"+clockOut[3]+":"+clockOut[4]+":"+clockOut[5]+"\n"+workedTimeToday[1]+":"+workedTimeToday[2]+workedTimeToday[3]+"\n"+festTimeToday[0]+"-"+festTimeToday[1]+":"+festTimeToday[2]+":"+festTimeToday[3];
}
else if(parseInt(workedSecondsToday[0].ToString()) > 0 && parseInt(workedSecondsToday[1].ToString()) > 0 && parseInt(workedSecondsToday[2].ToString()) > 0)
{
debugLog11 = "\nHora de Salida\nNormal:\nExtra:\nFestivo:"; //NORMAL + EXTRA + FESTIVO
debugLog12 = "\n"+clockOut[3]+":"+clockOut[4]+":"+clockOut[5]+"\n"+workedTimeToday[1]+":"+workedTimeToday[2]+workedTimeToday[3]+"\n"+extraTimeToday[0]+"-"+extraTimeToday[1]+":"+extraTimeToday[2]+":"+extraTimeToday[3]+"\n"+festTimeToday[0]+"-"+festTimeToday[1]+":"+festTimeToday[2]+":"+festTimeToday[3];
}
clockedOut = true;
clockedIn = false;
}
else
{
debugLog01 = mainMsg;
debugLog11 = "\n"+errorMsg2;
debugLog12 = "\n";
}
}
Can't explain myself better since I have no clue about what is happening. Any help will be much appreciated.
Yesterday, i started placing tons of labels everywhere in my code and finally discovered where it stopped.
It was just replacing this...
var sw = new StreamWriter(Application.persistentDataPath+"\\Settings.txt", false);
by...
var sw = new StreamWriter(Application.persistentDataPath+"/Settings.txt", false);
Only windows supports this bar "\" when used for setting paths, but i was thinking all the time that the error was somewhere in the OnGUI function.
Thanks lot to everyone who came helping me :)
On the Unity3D you can find this information:
Work with specific constraints (constraint):
Samsung Galaxy S (30 MB limit to downloadable file size, also problems with UI)
Samsung Galaxy Tab (30 MB limit to downloadable file size)
HTC Desire (40 MB limit to downloadable file size)
Samsung Galaxy S2 (Minor but possibly annoying issue: phone may work in 16-bit mode with Unity and show color banding Edit: a workaround was added to address the GS2 graphics driver, I don't know if it was related to this problem or not)
HTC EVO3D (Must build with Unity 3.4)
HTC Sensation (Must build with Unity 3.4)
Samsung Galaxy S2 (Minor but possibly annoying issue: phone may work in 16-bit mode with Unity and show color banding Edit: a workaround was added to address the GS2 graphics driver, I don't know if it was related to this problem or not)
Unity3D Android Limitations
this code has been working on both IOS and android
window.scrollTo(0,1);
but after the release of IOS7, is no longer working, so I ended up using this.
if((window.orientation == 90 || window.orientation == -90) && window.innerHeight != window.outerHeight)
it works on IOS 7 but not in android..
How can I make those two code work together? or is there any option to hide URL Address bar hide on both Android and IOS? Thanks.
This currently works with IOS7
function hideAddressBar() {
if (!window.location.hash) {
if (document.height < window.outerHeight)
document.body.style.height = (window.outerHeight + 50) + 'px';
setTimeout(function () {
window.scrollTo(0, 1);
document.body.style.height = 'auto';
}, 50);
}
}
I am using iScroll for providing iPhone style scrolling. But, when clicking on the textboxes, the keyboard does not show up.
While trying to find the possible cause, I found that removing the iScroll script, makes it work normal, but in that case I miss the scrolling functionality.
Is this a bug in iScroll. If yes, is there a tested work-around? Or is there any alternative for iScroll?
Thanks in advance.
At least in iScroll 4, you can add this code to enable clicking of input fields. See the demo on Form-fields in the examples folder.
<script type="text/javascript">
var myScroll;
function loaded() {
myScroll = new iScroll('wrapper', {
useTransform: false,
onBeforeScrollStart: function (e) {
var target = e.target;
while (target.nodeType != 1) target = target.parentNode;
if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA')
e.preventDefault();
}
});
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
document.addEventListener('DOMContentLoaded', loaded, false);
</script>
I was able to solve the error. The problem was with the CSS.
I thought may be the CSS is somehow creating the problem. I concluded this on the basis that when I commented the CSS for wrapper and scroller, the keyboard showed up... but keeping them, the keyboard didn't work. I was using bottom: 0px;, which seemed to be somehow preventing the keyboard from showing.
Removing bottom: 0px; solved my problem.
Hope this helps others.
I added the following code to _start in iScroll 4.2 to solve this problem:
if (e && e.target && e.target.tagName) {
var bFocusField = ('|INPUT|TEXTAREA|BUTTON|SELECT|'
.indexOf('|' + e.target.tagName + '|') >= 0);
if (bFocusField || that.focusField) {
if (bFocusField) {
that.focusField = e.target;
} else {
that.focusField.blur();
that.focusField = null;
}
e.defaultPrevented = false;
e.returnValue = true;
return true;
}
}
Code is inserted below the initialization part of the function (that.moved = false; ... that.dirY = 0;).
Tested it on iPad 1 (iOS 5.1) and iPad 3 (iOS 6). The onscreen keyboard does not seem to interfere with iScroll (I do an iScroll.refresh() every 5 seconds).
I believe this solution is optimal
Tweak the code in iscroll.js, ( as follows )
onBeforeScrollStart: function (e) {
//e.preventDefault();
if (e.target.nodeName.toLowerCase() == "select" || e.target.tagName.toLowerCase() == 'input' || e.target.tagName.toLowerCase() == 'textarea'){
return;
}
},