Dismiss the keyboard in uiwebview in case I d'ont want to submit the form - ios

I am developing a application in phonegap. In the app, there is a page which contains two textfields and a image. No submit button because I don't want to submit the form. the desired working is as follow..
the user taps the text fields, the keyboard appears.
clicking on the image below calls a javascript(jquery method-> $.post()) function which picks the data from the textfields and send it to server(json). that means I m not submitting the form.
and the go button on the virtual keyboard is supposed to submit the form. But in my case as I m not submitting the form so go button doesn't work and it doesn't look appropriate.
I want to get rid of the button..either it may dismiss the keyboard or call the jquery function which it is not supporting.
I searched a lot over the net. I came to know that if i remove the form tag the go button changes to return button which really worked then the return button again looks dumb.
So please help me to get rid of either of the button(preferably the return button).

I don't think you will be able to get rid off the button. What you could do instead, is to have the input field in form with and onsubmit event. This event should perform the jquery $.post method and return false to prevent standard form submission. This way your go button would actually work the way user expects and you don't have to disable it.

Related

How to have one button do both "enable" and "disable" in ASP.net MVC

I am new to ASP.Net MVC, and still trying to wrap my head around the controller and passing data to the view and back.
Here is my question. I have a model in my view with a property that is "isEnabled", which can be true or false.
I have an edit button, and an enable/disable button. Edit just takes me to a new view with a form.
I want the enable/disable button to change the property of the model to enabled or disabled.
Right now I have two separate buttons. When I click on them, it fires the appropriate action from the controller (EnableModel, DisableModel), and just reloads the current view.
How can I make it so, if the model is disabled the button shows and fires the enable action, and when it is enabled, the button shows and fires the disable action.
So here are the options I thought of.
1. Two buttons, I hide them as needed. I can use an if statement to check if the model is showing or not in razor.
2. Use javascript two to the above
3. Use javascript to physically change the button
What would be the best method?
Alright so looking back can't believe I ever even asked this haha.
I went the javascript route. I had a single button, and a simple onClick javascript class that would handle the toggling.

Screen not moving up after keyboard appears when user clicks on a text field inside UIWebView

I have an iPhone application where the content dynamically loads a form from a CMS. The form contains fields where a user needs to enter and submit, nothing tricky.
Unfortunately, when the user clicks on the form, the keyboard appears and it is hiding the UIWebView that is containing the form.
How am I able to resolve this?
Answering my own question.
My only solution at the moment is a hack:
At the end of the form tag, I simply added a dozen of non-breakable-space tags
This allows the UIWebview to scroll up hence showing the textbox to the user above the keyboard.

Angular/Bootstrap ui modal dialog with a form issue

I have an Angular JS app with a bootstrap ui modal dialogue hosting a simple edit form.
The form can be for a new "thing" or a populated "thing".
I find that when I cancel out of the modal with the form populated, submit is being called.
Any help appreciated.
Plunkr here... http://plnkr.co/edit/XhQCqlGUfcmQOhqLDeXR?p=preview
I forked your plunk and got it working here: http://plnkr.co/edit/jgg5pDQOH46XgrbW3Mvh?p=preview I think the cancel button was participating in the form submit event since it was inside the form element. Moving it outside of the form seems to have fixed the problem. I also set up the submit event to fire the modalInstance close event and the cancel event to fire the modalInstance dismiss event. This gives you the opportunity to handle things appropriately in the parent controller (ModalDemoCtrl).
EDIT
You could also stop the click event from propagating in the cancel event and still use the save as an input element inside the form tag. See this plunk for example: http://plnkr.co/edit/A81KkUUQEL3IBbOSnHQb?p=preview
I was having a similar problem. My problem was that when I clicked in the button to open the modal, my form was submited. I was using a "button" html tag, without specifying the "type" attribute. So, I found your problem and I went to the W3C documentation. I found that:
Tip: Always specify the type attribute for a button element. Different browsers use different default types for the button element. (http://www.w3schools.com/tags/tag_button.asp)
I wasn't defining the type of my button, so the default type of my browser was submit. I defined the type to "button" and everything is ok now.

What is the best way to allow canceling of a modal form when there is field level validation?

What is the best way to allow canceling of a modal form when there is field level validation?
I have a Delphi form shown modally. In it there are TComboBoxes, TEdits, an Ok and Cancel buttons. These fields have OnExit methods the fire to check that the data is valid. However, I would like to have the Cancel button click allow the form to close without validating the fields. What happens is when the Cancel button is clicked, then the OnExit of the field is called and validation is run before the OnClick of the button which closes the form. This timing is undesirable because it causes the user to correct data that they wish to abandon. Thanks.
I abandoned data validation "on field exit" altogether. It frustrates users who know what they're doing (for example, someone may be copying data from another source and pasting on the current screen, in a way that will only make sense only when all data is pasted in--validation per field usually gets on the way of such actions).
Instead, try performing data validation when the user is ready to move on from the current screen, usually when they click the "OK" or "Next" button.

MVC question - hide /show a panel with partial postback from radiobutton submit

I have 2 radio button with values New & Existing. If user chooses New, then I show a textbox on the form and if Existing a dropdown and textbox is hidden. The question is , does the hide/show of the textbox/dropdownlist have to be written in the View or the Controller class? Also when I choose the selection my whole form is posting back and hence all validation error msgs are being shown which should not be shown nless the save button is clicked, how do I a partial postback without full form submission? Any code snippets or urls would be benificial in this respect.
The question is , does the hide/show of the textbox/dropdownlist have to be written in the View or the Controller class?
Just show/hide with jQuery that.
Also when I choose the selection my whole form is posting back and hence all validation error msgs are being shown which should not be shown nless the save button is clicked, how do I a partial postback without full form submission? Any code snippets or urls would be benificial in this respect.
Perform 'partial postbacks' through javascript.
Post form to save action only once when it's ready (when Save button is clicked).
Some resources:
jQuery tutorial
jQuery AJAX
About form AJAX`ifying
If I understand you correctly, the answer is the hiding and showing of controls should be done on the view as it's display specific.
If you use javascript to show and hide the controls then because it's on the client side you would not have to postback the form, and could do server side validation when the save button is clicked.
jQuery is very good: Jquery Website
Hope that helps?

Resources