This content has been marked as final.
Show 7 replies
-
1. Re: JS field validation
Harbs. Jul 9, 2008 10:16 PM (in response to John.Kordas)Use a self-calling function to show the dialog again if the field is empty.
Harbs -
2. Re: JS field validation
John.Kordas Jul 9, 2008 10:40 PM (in response to John.Kordas)Thanks Harbs,
Do you mean somthing like:
}else{
alert("Please enter some text into the contents field.");
myDialog.show();
}
I tried this but it only worked once then the dialog closed on the third click of the ok button. -
3. Re: JS field validation
Loic_aigon Jul 10, 2008 1:29 AM (in response to John.Kordas)function mydialog()
{
var mydialog = app.dialogs.add();
//your dialog creation script
if(mydialog.show()!= null)
{
if(myTextEditField.editContents == "")
{
mydialog();
}
else
{
// doSomethingHere();
}
}
}
function doSomethingHere()
{
//do something;
}
mydialog(); -
4. Re: JS field validation
John.Kordas Jul 10, 2008 3:30 PM (in response to John.Kordas)Thanks Ioic_aigon,
working through what you have I get a error Object is undefined:
function mydialog()
{
var mydialog = app.dialogs.add();
//your dialog creation script
with(mydialog){
//Add a dialog column.
with(dialogColumns.add()){
//Create a text edit field.
//var myTextEditField = textEditboxes.add({editContents:"Hello World!",minWidth:180});
var myTextEditField = textEditboxes.add({minWidth:180});
//Create a number (real) entry field.
var myPointSizeField = realEditboxes.add({editValue:72});
}
}
if(mydialog.show()!= null)
{
if(myTextEditField.editContents == "")
{
alert("Please enter some text into the contents field.");
b mydialog(); <==== Object is undefined
}
else
{
// doSomethingHere();
}
}
}
function doSomethingHere()
{
//do something;
}
mydialog(); -
5. Re: JS field validation
John.Kordas Jul 10, 2008 3:51 PM (in response to John.Kordas)This is also most working it will bring the dialog back up after you click the ok on the alert. The only problem now is the Cancel will not work unless you enter somthing in the text field.
function validate(){
var myDialog = app.dialogs.add({name:"Simple User Interface Example Script",canCancel:true});
with(myDialog){
//Add a dialog column.
with(dialogColumns.add()){
//Create a text edit field.
//var myTextEditField = textEditboxes.add({editContents:"Hello World!",minWidth:180});
var myTextEditField = textEditboxes.add({minWidth:180});
//Create a number (real) entry field.
var myPointSizeField = realEditboxes.add({editValue:72});
}
}
//Display the dialog box.
var myResult = myDialog.show();
if(myTextEditField.editContents == "")
{
alert("Please enter some text into the contents field.");
validate();
}else{
if(myResult == true){
//Get the values from the dialog box controls.
var myString = myTextEditField.editContents;
var myPointSize = myPointSizeField.editValue;
//Remove the dialog box from memory.
myDialog.destroy();
//Create a new document.
var myDocument = app.documents.add()
}
else{
//User clicked Cancel, so remove the dialog box from memory.
myDialog.destroy();
}
}
}
validate(); -
6. Re: JS field validation
John.Kordas Jul 10, 2008 4:04 PM (in response to John.Kordas)Ok to get he above code to work I changed:
if(myTextEditField.editContents == "")
to
if(myResult == true && myTextEditField.editContents == "")
If anyone can see anything wrong with the way I've gone about it please leat me know.
Cheers. -
7. Re: JS field validation
Loic_aigon Jul 11, 2008 12:30 AM (in response to John.Kordas)Hi John,
The script is on the way !
You if con,dition may be simplier :
if(myTextEditField.editContents == "") //entry is ""
{
alert("Please enter some text into the contents field.");
validate();
}
else if(myResult == true) //user entered datas
{
//action here
}
else //implies user clicked cancel
{
myDialog.destroy();
}



