Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Contributor
blacksanta_69
Posts: 2
Registered: ‎07-26-2013
My Device: Q10
My Carrier: na

BB10 Formcontrol Submit can't be stopped

[ Edited ]

I'm using a form in a phonegap app for bb10. I'd like to keep the form so the on-screen keyboard 'Previous' and 'Next' buttons can be used. However, there is no way to suppress the form from submitting to the 'action' when the on-screen keyboard submit button is used. It also appears to always use method='get', which isn't ideal. A normal html submit button works as expected when I 'return false;' onSubmit - only the on-screen keyboard Submit button can't be stopped. I'm using the Simulator browser to test, but the behaviour is the same on device and appears true for html in browser as well as wrapped in PhoneGap.

<script type="text/javascript">
<!--
function submitHandler()
{
    return false;
}
-->
</script>
<form onSubmit="submitHandler();" action="">
<input type="text" value="" placeholder="test1" name="test1" class="input-field" id="test1">
<input type="text" value="" placeholder="test2" name="test2" class="input-field" id="test2">
<input type="submit" value="submit" onClick="return false;"/>
</form>

I'd rather do validation and submission in other parts of my code. The way it works now, I can't stop submission if the form is invalid. Is there a way to suppress the form from submitting when using the OSK submit button?

Please use plain text.
Administrator
astanley
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: BB10 Formcontrol Submit can't be stopped

The code snippet you have posted is indicative of server-side technology (is it .NET ? ). 

 

Since PhoneGap generats a fully-featured client app, why not do all of your form processing on the client-side, rather that posting data to a remote server?  When do you these postbacks, the user experience is generally poor (especially on mobile) as you need to wait for an HTTP response, and also worry about re-populating input field(s) with data.

 

>>The way it works now, I can't stop submission if the form is invalid

Rather than doing an HTTP request and reload the page, create a JavaScript "onClick" function that is tied to the button click event. Have this method validate your input fields and process the data.

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Please use plain text.
New Contributor
blacksanta_69
Posts: 2
Registered: ‎07-26-2013
My Device: Q10
My Carrier: na

Re: BB10 Formcontrol Submit can't be stopped

[ Edited ]

Thanks for the response.

 

>> Rather than doing an HTTP request and reload the page, create a JavaScript "onClick" function that is tied to the button click event. Have this method validate your input fields and process the data.

>>  

I may have been unclear - I am doing the validation client side. I have a button that performs validation as expected - in the code snippet, touching the html button works and stops the form from performing the action: <input type="submit" value="submit" onClick="return false;"/>.

 

The issue I'm having is only when I use the On Screen Keyboard submit 'key' - any attempt to stop the form submission is ignored - 'return false' is ignored and the view proceeds to whatever was specified in the form action and the method is ignored and always 'get'.

 

My expectation is that touching the On Screen Keyboard submit key will fire the form onSubmit, recieve the value 'false' and not submit, as it does in a non-BB10 browser. Instead, the view 'gets' the data from the form to whatever the action is.

Please use plain text.