i am pretty much new to javafx. i have built an application on javafx which will load index.html page through WebView. when i click on register button in index.html new registration form page will be loaded.
javafx code:
public void start(final Stage primaryStage) throws Exception {
primaryStage.setResizable(false);
FrontEndFinal f=new FrontEndFinal();
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
webEngine.setJavaScriptEnabled(true);
Worker<Void> worker = webEngine.getLoadWorker();
worker.stateProperty().addListener(new ChangeListener<State>() {
public void changed(ObservableValue<? extends State> observable, //
State oldValue, State newValue) {
// When load successed.
if (newValue == Worker.State.SUCCEEDED) {
JSObject jsobj = (JSObject) webEngine.executeScript("window");
jsobj.setMember("myJavaMember", new FrontEndFinal());
}
}
});
VBox root = new VBox();
root.setMinHeight(500);
root.setMinWidth(1250);
System.out.println(System.getProperty("user.dir"));
String p=System.getProperty("user.dir");
String [] t=p.split("\\\\");
System.out.println(t.length);
String final1=t[0]+"/";
for(int i=1;i<t.length;i++)
{
final1=final1+t[i]+"/";
}
System.out.println(final1);
browser.getEngine().load("file:///"+final1+"/Html"+"/SMS.html");
root.getChildren().add(browser);
}
When I run this code it loads index.html
in Index.html:
<button class="dropbtn" onclick="location.href = 'Registration.html'"><b>< Register ></b></button>
after clicking button it opens Registration.html
In Registration.html
<form name="myForm" method="post">
Name: <input type="text" name="fname">
<button type="button" name="Submit" onclick="abc()">Submit</button>
<script>
function abc(){
window.alert("Invalid name");
}
Now my problem is when i submit Registration.html form with name field blank, it does not shows alert box i googled many sites like:[https://community.oracle.com/thread/2540279] but didn't work Any help or suggestions?
Thanks In Advance