1

Want to display javascript validation messages inside an html popup window which would be a seperate html page.currently it is displayed on the same page from where it has been called.

 $("#getStarted").val('Try xxxx for Free');
 $('#message1').text('User ' + emailID + ' already exists.');
 $("#stRegister").val("");
 document.getElementById("stRegister").focus();
<input name="stRegister" id="stRegister" type="email" class="registerinput" placeholder="Enter your business email ID" onkeypress="$('#message1').text('');">

 <div class="col-md-4 col-md-offset-6 hidden-xs hidden-sm">
 <div style="margin-left:8px;" class="alerts" id="message1">
 </div>
</div>
Abhi
  • 41
  • 2
  • 9
  • Your requirement seems to be unconventional – M14 Jun 06 '18 at 10:48
  • Yep, I think he just wanted to say display an HTML block inside a Js popup – andrea06590 Jun 06 '18 at 10:52
  • So what is your actual _question_ then? (“I want” is _not_ a proper question/problem description; please go read [ask] if you have not done so yet.) How to open a popup window? Easy enough to research. How to get access to the document inside the popup and manipulate or replace it? Also something you should try and research yourself first. – CBroe Jun 06 '18 at 10:55
  • Maybe local storage? Try this https://stackoverflow.com/questions/27765666/passing-variable-through-javascript-from-one-html-page-to-another-page – A. Meshu Jun 06 '18 at 11:41

3 Answers3

0

var window = window.open(url, windowName, [windowFeatures]); moidify the dom on the window object.

kpie
  • 9,588
  • 5
  • 28
  • 50
  • Tried this popupWindow = window.open('xxxxx.html', 'xxxxx', 'top=300,left=450,width=500,height=200,resizable=no'); But want to display message inside xxxxx.html. – Abhi Jun 06 '18 at 10:57
0

Not sure if you can do it in a separate window. However, for validation you can use the window.confirm function natively build into the browsers. Here is an example:

// window.confirm returns a boolean based on the user action
let validate = window.confirm('Do you want to continue?');

if (validate) {
  console.log('validated');
} else {
  console.log('not validated');
}
Willem van der Veen
  • 33,665
  • 16
  • 190
  • 155
-1

You can use in your script something like:

window.alert("what you want here");