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");
}
Related
I'm trying to figure out how to get information from a dictionary API in Gamemaker Studio 1.4.9
I'm lost since I can't figure out how to get around the API's server block. All my return shows is a blank result.
Step Event:
if(keyboard_check_pressed(vk_space)){
http_get("https://api.dictionaryapi.dev/api/v2/entries/en/test");
}
HTTP Event:
var requestResult = ds_map_find_value(async_load, "result");
var resultMap = json_decode(requestResult);
if(resultMap == -1)
{
show_message("Invalid result");
exit;
}
if(ds_map_exists(resultMap,"word")){
var name= ds_map_find_value(resultMap, "word");
show_message("The word name is "+name);
}
Maybe my formatting is wrong? It's supposed to say the word test in the show_message function, but again, all I get returned is a blank result.
Any help would be appreciated, thanks!
You can see through the debugger that the data is coming from the server. But your code does not correctly try to retrieve the Word.
https://imgur.com/a/icQSnnx
This code gets this word
show_debug_message("http received")
var requestResult = ds_map_find_value(async_load, "result");
var resultMap = json_decode(requestResult);
if(resultMap == -1)
{
show_message("Invalid result");
exit;
}
if(ds_map_exists(resultMap,"default")){
var defaultList = ds_map_find_value(resultMap, "default")
var Map = ds_list_find_value(defaultList, 0)
var name= ds_map_find_value(Map, "word");
show_message("The word name is "+name);
}
I am trying to mimic the autosave function in GMS v3 so that I can use in version 1 and 2. I would like to first acknowledge that the main bulk of the script originates from Dr Bernhard Schaffer's "How to script... Digital Micrograph Scripting Handbook". I have modified it a bit, so that any new image recorded by the camera can be autosave into the file. However, I met some problems because if I decide to click on live-view image and move the image around, or using live-fft, the live view image or the FFT image will be saved as well. One of the ideas I have is to use the taggroup information such as the "Acquisition:Parameters:Parameter Set Name" because for live view or live-FFT, this would be either in search or focus mode. Another idea is to use the document ID e.g iDocID = idoc.ImageDocumentGETID() to locate the ID of the live image. However, i am clueless then how to use this information to exclude them from autosaving. Can anyone point to me how i can proceed with this script?
Below is the script
Class PeriodicAutoSave : Object
{
Number output
PeriodicAutoSave(Object self) Result("\n Object ID"+self.ScriptObjectGetID()+" created.")
~PeriodicAutoSave(Object self) Result("\n Object ID"+self.ScriptObjectGetID()+" destroyed")
Void Init2(Object self, Number op)
output=op
Void AutoSave_SaveAll(Object self)
{
String path, name, targettype, targettype1, area, mag, mode, search, result1
ImageDocument idoc
Number nr_idoc, count, index_i, index, iDocID, iDocID_search
path = "c:\\path\\"
name = "test"
targettype=="Gatan Format (*.dm4)"
targettype1 = "dm4"
If (output) Result("\n AutoSave...")
nr_idoc = CountImageDocuments()
For (count = 1; count<nr_idoc; count++)
{
idoc = GetImageDocument(count) //imagedocument
index = 1 // user decide the index to start with
index_i= nr_idoc - index
If (idoc.ImageDocumentIsDirty())
{
idoc = getfrontimagedocument()
iDocID = idoc.ImageDocumentGetID()
TagGroup tg = ImageGetTagGroup(idoc.ImageDocumentGetImage(0)) // cannot declare an 'img' for this line as it will prompt an error?
tg.TagGroupGetTagAsString("Microscope Info:Formatted Indicated Mag", mag)
Try{
{
idoc.ImageDocumentSavetoFile( "Gatan Format", path+index_i+"-"+name+"-"+mag+".dm4")
idoc.ImageDocumentSetName(index_i + "-"+name+"-"+mag+".dm4")
idoc.ImageDocumentClean()
}
If (Output) Result("\n\t saving: "+idoc.ImageDocumentGetCurrentFile())
}
Catch{
Result("\n image cannot be saved at the moment:" + GetExceptionString())
Break
}
Result("\ Continue autosave...")
}
}
}
}
Void LaunchAutoSave()
{
Object obj = Alloc(PeriodicAutoSave)
obj.Init2(2)
Number task_id = obj.AddMainThreadPeriodicTask("AutoSave_SaveALL",6)
//Sleep(10)
while(!shiftdown()) 1==2
RemoveMainThreadTask(task_id)
}
LaunchAutoSave()
thank you very much for your pointers! I have tried and it works very well with my script. as the 'TagGroupDoesTagExist' only refers to the taggroup, I modified further to include the tags I want to filter e.g "Search" or "Focus" and it seems to work well. The script that I modified to your existing ones is as below :
If (idoc.ImageDocumentIsDirty())
{
//now find out what is a filter condition and skip if it is true
skip = 0
TagGroup tg = idoc.ImageDocumentGetImage(0).ImageGetTagGroup()
tg.TagGroupGetTagAsString("Microscope Info:Formatted Indicated Mag", mag)
tg.TagGroupGetTagAsString("Acquisition:Parameters:Parameter Set Name", mode)
skip = tg.TagGroupDoesTagExist("Acquisition:Parameters:Parameter Set Name")
if(skip && (mode == "Search" || mode== "Focus")) continue
Your idea of filtering is a good one, but there is something strange with your for loop.
in
nr_idoc = CountImageDocuments()
For (count = 1; count<nr_idoc; count++)
{
idoc = GetImageDocument(count) //imagedocument
you iterate over all currently open imageDocuments (except the first one!?) and get them one by one, but then in
If (idoc.ImageDocumentIsDirty())
{
idoc = getfrontimagedocument()
you actually get the front-most (selected) document instead each time. Why are you doing this?
Why not go with:
number nr_idoc = CountImageDocuments()
for (number count = 0; count<nr_idoc; count++)
{
imagedocument idoc = GetImageDocument(count)
If (idoc.ImageDocumentIsDirty())
{
// now find out what is a filter condition and skip if it is true
number skip = 0
TagGroup tg = idoc.ImageDocumentGetImage(0).ImageGetTagGroup()
skip = tg.TagGroupDoesTagExist("Microscope Info:Formatted Indicated Mag")
if (skip) continue
// do saving
}
}
i am not able to figure out why the focusout validation that uses the assigned regex is not working in the devex textbox. when i am using the textbox out of the grid it starts working as required. Kindly suggest the solution.
#Html.DevExpress().GridView(settings =>
{
settings.Columns.Add(column =>
{
column.FieldName = "InYear";
column.Caption = "In Year";
column.Width = 100;
column.ColumnType = MVCxGridViewColumnType.TextBox;
column.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending; // Default
column.SortIndex = 1;
column.CellStyle.HorizontalAlign = HorizontalAlign.Left;
var txtProperties = column.PropertiesEdit as TextBoxProperties;
txtProperties.Width = Unit.Percentage(100);
txtProperties.MaxLength = 4;
txtProperties.DisplayFormatInEditMode = true;
txtProperties.ValidationSettings.RequiredField.IsRequired = true;
txtProperties.ValidationSettings.ValidateOnLeave = true;
txtProperties.ValidationSettings.RegularExpression.ValidationExpression = #"\d{4}";
txtProperties.ValidationSettings.RegularExpression.ErrorText = "Expected format is: YYYY";
txtProperties.ClientSideEvents.ValueChanged = String.Format("function (s, e) {{ OnValueChanged(s, e, '{0}', {1}); }}", "InYear", "0");
column.SetDataItemTemplateContent(c =>
{
if (!(bool)DataBinder.Eval(c.DataItem, "ReadOnly"))
{
Html.DevExpress().TextBox(txtSettings =>
{
txtSettings.Name = "txtInYear_" + c.KeyValue.ToString();
txtSettings.Width = Unit.Percentage(100);
txtSettings.Properties.MaxLength = 4;
txtSettings.Properties.DisplayFormatInEditMode = true;
txtSettings.Properties.ValidationSettings.ValidateOnLeave = true;
txtSettings.Properties.ValidationSettings.ValidationGroup = c.KeyValue.ToString();
txtSettings.Properties.ValidationSettings.RegularExpression.ValidationExpression = #"[0-9]{4}";
txtSettings.Properties.ValidationSettings.RegularExpression.ErrorText = "Expected format is: YYYY";
txtSettings.Properties.ClientSideEvents.ValueChanged = String.Format("function (s, e) {{ OnValueChanged(s, e, '{0}', {1}); }}", c.Column.FieldName, c.KeyValue);
}).Bind(DataBinder.Eval(c.DataItem, c.Column.FieldName)).Render();
}
else
Html.DevExpress().Label(lblSettings =>
{
lblSettings.Name = "lblInYear_" + c.KeyValue.ToString();
lblSettings.Width = Unit.Percentage(100);
}).Bind(DataBinder.Eval(c.DataItem, c.Column.FieldName).ToString()).Render();
});
});
}).Bind(Model).GetHtml()
EDIT : I am using a button out of the gridview to trigger the update command. How can i trigger only validate event of the EditRow. Please view attached image.
Thanks in advance
When do you need to validate the TextBox? In browser mode or when editing? Currently your TextBox is required when you edit a row. Try to set the IsRequired property for your TextBox in the template as well.
txtSettings.Properties.ValidationSettings.RequiredField.IsRequired = true;
It should work.
Go through this thread - MVC GridView - Client validation in default EditForm.
In case if you are working with ajax form then i suggest you use
built-in validation instead:GridView - How to use Microsoft
validation with an AJAX form to validate the Model properties on the
client side.
More References:
GridView - How to enable the client-side validation in the Edit Form
How to correctly enable Model, Unobtrusive or jQuery Client validation
Client Validation in MVC3 with Gridview Template Form
After a long struggle i got the following answer :
Assign a validation group property to the nested controls as below
txtSettings.Properties.ValidationSettings.ValidationGroup = c.KeyValue.ToString();
Iterate through the keyvalues on client side and call the devexpress validate function ASPxClientEdit.ValidateEditorsInContainer as following, i represent validation group name
var isValid =!ASPxClientEdit.ValidateEditorsInContainer(GridName.GetMainElement(), i)
My approach might not be the best but it helped me a lot, i think this would also be helpful for others having the same issue.
Thanks.....
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?
Can someone give me an example of the use of SPStatefulLongOperation? It's very poorly documented.
Here's an example of code I've just used. It applies a ThmxTheme (selectedTheme) to all SPWebs in an SPSite (site).
SPStatefulLongOperation.Begin(
"Applying theme to sites.",
"<span id='trailingSpan'></span>",
(op) =>
{
op.Run((opState) =>
{
for (int i = 0; i < site.AllWebs.Count; i++)
{
// Update status.
opState.Status = String.Format(
"<script type='text/javascript'>document.all.item('trailingSpan').innerText = '{0} ({1} of {2})';</script>",
site.AllWebs[i].Title,
i + 1,
site.AllWebs.Count);
// Set the theme.
selectedTheme.ApplyTo(site.AllWebs[i], true);
}
});
op.End(System.Web.HttpContext.Current.Request.UrlReferrer.ToString());
});
Note that the current value of opState.State is appended to the client's HTML (via HttpContext.Current.Response.Write and .Flush) every second. Thus you don't want to send any status message directly; you want to send some JavaScript that will update an existing status element on the page. (Here, the trailingSpan element.)